diff --git a/doc/telescope.txt b/doc/telescope.txt index 3aad0466ab..5c8e521d4f 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -1613,7 +1613,9 @@ builtin.lsp_references({opts}) *telescope.builtin.lsp_references()* only one and the definition file is different from the current file, values: "tab", "tab drop", "split", - "vsplit", "never" + "vsplit", "never" or a function, + which will be executed before the + jump {show_line} (boolean) show results text (default: true) {trim_text} (boolean) trim results text (default: false) {reuse_win} (boolean) jump to existing window if buffer is @@ -1661,7 +1663,9 @@ builtin.lsp_definitions({opts}) *telescope.builtin.lsp_definitions()* {jump_type} (string) how to goto definition if there is only one and the definition file is different from the current file, values: "tab", "tab - drop", "split", "vsplit", "never" + drop", "split", "vsplit", "never" or a function, + which will be executed before the + jump {show_line} (boolean) show results text (default: true) {trim_text} (boolean) trim results text (default: false) {reuse_win} (boolean) jump to existing window if buffer is @@ -1681,7 +1685,9 @@ builtin.lsp_type_definitions({opts}) *telescope.builtin.lsp_type_definitions()* {jump_type} (string) how to goto definition if there is only one and the definition file is different from the current file, values: "tab", "tab - drop", "split", "vsplit", "never" + drop", "split", "vsplit", "never" or a function, + which will be executed before the + jump {show_line} (boolean) show results text (default: true) {trim_text} (boolean) trim results text (default: false) {reuse_win} (boolean) jump to existing window if buffer is @@ -1701,7 +1707,9 @@ builtin.lsp_implementations({opts}) *telescope.builtin.lsp_implementations()* {jump_type} (string) how to goto implementation if there is only one and the definition file is different from the current file, values: "tab", "tab - drop", "split", "vsplit", "never" + drop", "split", "vsplit", "never" or a function, + which will be executed before the + jump {show_line} (boolean) show results text (default: true) {trim_text} (boolean) trim results text (default: false) {reuse_win} (boolean) jump to existing window if buffer is diff --git a/lua/telescope/builtin/__lsp.lua b/lua/telescope/builtin/__lsp.lua index 662a6af9b9..f758f78e8c 100644 --- a/lua/telescope/builtin/__lsp.lua +++ b/lua/telescope/builtin/__lsp.lua @@ -234,6 +234,8 @@ local function list_or_jump(action, title, funname, params, opts) cmd = "vnew" elseif opts.jump_type == "tab drop" then cmd = "tab drop" + elseif type(opts.jump_type) == "function" then + opts.jump_type() end if cmd then diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index 6e27c27ab3..c45d8598fe 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -423,7 +423,7 @@ builtin.jumplist = require_on_exported_call("telescope.builtin.__internal").jump ---@param opts table: options to pass to the picker ---@field include_declaration boolean: include symbol declaration in the lsp references (default: true) ---@field include_current_line boolean: include current line (default: false) ----@field jump_type string: how to goto reference if there is only one and the definition file is different from the current file, values: "tab", "tab drop", "split", "vsplit", "never" +---@field jump_type string: how to goto reference if there is only one and the definition file is different from the current file, values: "tab", "tab drop", "split", "vsplit", "never" or a function, which will be executed before the jump ---@field show_line boolean: show results text (default: true) ---@field trim_text boolean: trim results text (default: false) ---@field reuse_win boolean: jump to existing window if buffer is already opened (default: false) @@ -446,7 +446,7 @@ builtin.lsp_outgoing_calls = require_on_exported_call("telescope.builtin.__lsp") --- 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 goto definition if there is only one and the definition file is different from the current file, values: "tab", "tab drop", "split", "vsplit", "never" +---@field jump_type string: how to goto definition if there is only one and the definition file is different from the current file, values: "tab", "tab drop", "split", "vsplit", "never" or a function, which will be executed before the jump ---@field show_line boolean: show results text (default: true) ---@field trim_text boolean: trim results text (default: false) ---@field reuse_win boolean: jump to existing window if buffer is already opened (default: false) @@ -456,7 +456,7 @@ builtin.lsp_definitions = require_on_exported_call("telescope.builtin.__lsp").de --- Goto the definition of the type 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 goto definition if there is only one and the definition file is different from the current file, values: "tab", "tab drop", "split", "vsplit", "never" +---@field jump_type string: how to goto definition if there is only one and the definition file is different from the current file, values: "tab", "tab drop", "split", "vsplit", "never" or a function, which will be executed before the jump ---@field show_line boolean: show results text (default: true) ---@field trim_text boolean: trim results text (default: false) ---@field reuse_win boolean: jump to existing window if buffer is already opened (default: false) @@ -465,7 +465,7 @@ builtin.lsp_type_definitions = require_on_exported_call("telescope.builtin.__lsp --- 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 goto implementation if there is only one and the definition file is different from the current file, values: "tab", "tab drop", "split", "vsplit", "never" +---@field jump_type string: how to goto implementation if there is only one and the definition file is different from the current file, values: "tab", "tab drop", "split", "vsplit", "never" or a function, which will be executed before the jump ---@field show_line boolean: show results text (default: true) ---@field trim_text boolean: trim results text (default: false) ---@field reuse_win boolean: jump to existing window if buffer is already opened (default: false)