summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/builtin/init.lua2
-rw-r--r--lua/telescope/builtin/lsp.lua9
2 files changed, 10 insertions, 1 deletions
diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua
index e4b34e2..b1153ee 100644
--- a/lua/telescope/builtin/init.lua
+++ b/lua/telescope/builtin/init.lua
@@ -316,10 +316,12 @@ builtin.lsp_references = require("telescope.builtin.lsp").references
--- Goto the definition of the word under the cursor, if there's only one, otherwise show all options in Telescope
---@param opts table: options to pass to the picker
+---@field jump_type string: how to go to definition if there is only one, values: "tab", "split", "vsplit", "never"
builtin.lsp_definitions = require("telescope.builtin.lsp").definitions
--- Goto the implementation of the word under the cursor if there's only one, otherwise show all options in Telescope
---@param opts table: options to pass to the picker
+---@field jump_type string: how to go to implementation if there is only one, values: "tab", "split", "vsplit", "never"
builtin.lsp_implementations = require("telescope.builtin.lsp").implementations
--- Lists any LSP actions for the word under the cursor which can be triggered with `<cr>`
diff --git a/lua/telescope/builtin/lsp.lua b/lua/telescope/builtin/lsp.lua
index dccda5d..42a1851 100644
--- a/lua/telescope/builtin/lsp.lua
+++ b/lua/telescope/builtin/lsp.lua
@@ -64,7 +64,14 @@ local function list_or_jump(action, title, opts)
if #flattened_results == 0 then
return
- elseif #flattened_results == 1 then
+ elseif #flattened_results == 1 and opts.jump_type ~= "never" then
+ if opts.jump_type == "tab" then
+ vim.cmd "tabedit"
+ elseif opts.jump_type == "split" then
+ vim.cmd "new"
+ elseif opts.jump_type == "vsplit" then
+ vim.cmd "vnew"
+ end
vim.lsp.util.jump_to_location(flattened_results[1])
else
local locations = vim.lsp.util.locations_to_items(flattened_results)