nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
15.94k stars 838 forks source link

Running lsp_definition with jump_type "vsplit" create empty buffer #2469

Closed ilhamfu closed 1 year ago

ilhamfu commented 1 year ago

Description

running lsp_definitions with jump_type vsplit create an empty buffer for some reason, it didn't happen with default jump_type. also happen with jump_type split and tab

Neovim version

NVIM v0.9.0
Build type: Release
LuaJIT 2.1.0-beta3

Operating system and version

Archlinux

Telescope version / branch / rev

telescope 0.1.1

checkhealth telescope

telescope: require("telescope.health").check()

Checking for required plugins ~
- OK plenary installed.
- OK nvim-treesitter installed.

Checking external dependencies ~
- OK rg: found ripgrep 13.0.0
- OK fd: found fd 8.6.0

===== Installed extensions ===== ~

Telescope Extension: `file_browser` ~
- No healthcheck provided

Telescope Extension: `fzf` ~
- OK lib working as expected
- OK file_sorter correctly configured
- OK generic_sorter correctly configured

Telescope Extension: `notify` ~
- No healthcheck provided

Steps to reproduce

just run telescope builtin lsp_definitions with jump_type split,vsplit or tab

Expected behavior

only open file

Actual behavior

open file and another empty buffer

Minimal config

//using LazyVim
local telescope = require("telescope")
local telescope_actions = require("telescope.actions")
local telescope_builtin = require("telescope.builtin")

return {
  {
    "telescope.nvim",
    dependencies = {
      {
        "nvim-telescope/telescope-fzf-native.nvim",
        build = "make",
        config = function()
          telescope.load_extension("fzf")
        end,
      },
      {
        "nvim-telescope/telescope-file-browser.nvim",
        config = function()
          telescope.load_extension("file_browser")
        end,
        keys = {},
      },
    },
    keys = {
      { ";f", require("lazyvim.util").telescope("files"), desc = "Find Files (Root Dir)" },
      { ";F", require("lazyvim.util").telescope("files", { cwd = false }), desc = "Find Files (CWD)" },
      {
        "gdd",
        function()
          telescope_builtin.lsp_definitions({
            jump_type = "vsplit",
          })
        end,
        desc = "Goto Definition",
      },
      {
        "gd",
        function()
          telescope_builtin.lsp_definitions()
        end,
        desc = "Goto Definition",
      },
      {
        "gr",
        function()
          telescope_builtin.lsp_references()
        end,
        desc = "Goto References",
      },
      {
        "gr",
        function()
          telescope_builtin.lsp_implementations()
        end,
        desc = "Goto References",
      },
      {
        ";w",
        function()
          telescope.extensions.file_browser.file_browser({
            hide_parent_dir = true,
            path = "%:p:h",
            quite = true,
            files = true,
            grouped = true,
            sorting_strategy = "ascending",
            layout_strategy = "bottom_pane",
            layout_config = {
              anchor = "SW",
              prompt_position = "bottom",
              preview_cutoff = 0,
            },
            initial_mode = "normal",
            preview = {},
            attach_mappings = function(_, map)
              map("n", "l", telescope_actions.select_default)
              map("n", "h", require("telescope._extensions.file_browser.actions").goto_parent_dir)
              return true
            end,
          })
        end,
        desc = "Dir Finder",
      },
    },
    opts = {
      defaults = {
        mappings = {
          i = {
            ["<C-j>"] = {
              telescope_actions.move_selection_next,
              type = "action",
              opts = {
                nowait = true,
                silent = true,
              },
            },
            ["<C-k>"] = {
              telescope_actions.move_selection_previous,
              type = "action",
              opts = { nowait = true, silent = true },
            },
            ["<leader>w"] = {
              telescope_actions.select_vertical,
              type = "action",
              opts = { nowait = true, silent = true },
            },
            ["<leader>h"] = {
              telescope_actions.select_horizontal,
              type = "action",
              opts = { nowait = true, silent = true },
            },
            ["<leader>t"] = {
              telescope_actions.select_tab,
              type = "action",
              opts = { nowait = true, silent = true },
            },
          },
          n = {
            ["<leader>w"] = telescope_actions.select_vertical,
            ["<leader>h"] = telescope_actions.select_horizontal,
            ["<leader>t"] = telescope_actions.select_tab,
          },
        },
      },
    },
  },
  {
    "nvim-neo-tree/neo-tree.nvim",
    enabled = false,
  },
}
jamestrew commented 1 year ago

I'm not able to replicate this using :Telescope lsp_definitions jump_type=vsplit (or calling via lua) in a lua file. Also using v0.1.1.

Can you provide more details about which lsp you're using?

ilhamfu commented 1 year ago

i tried it with lua_ls and tsserver, it has the same problem

jamestrew commented 1 year ago

closing this as it's a duplicate of #2368