fix: apply jump_type only if the definition file is different from the current file (#2324)
This commit is contained in:
@@ -24,3 +24,11 @@ globals = {
|
|||||||
read_globals = {
|
read_globals = {
|
||||||
"vim",
|
"vim",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
files = {
|
||||||
|
["lua/telescope/builtin/init.lua"] = {
|
||||||
|
ignore = {
|
||||||
|
"631", -- allow line len > 120
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|||||||
@@ -1454,8 +1454,10 @@ builtin.lsp_references({opts}) *telescope.builtin.lsp_references()*
|
|||||||
{include_current_line} (boolean) include current line (default:
|
{include_current_line} (boolean) include current line (default:
|
||||||
false)
|
false)
|
||||||
{jump_type} (string) how to goto reference if there is
|
{jump_type} (string) how to goto reference if there is
|
||||||
only one, values: "tab", "split",
|
only one and the definition file is
|
||||||
"vsplit", "never"
|
different from the current file,
|
||||||
|
values: "tab", "split", "vsplit",
|
||||||
|
"never"
|
||||||
{fname_width} (number) defines the width of the filename
|
{fname_width} (number) defines the width of the filename
|
||||||
section (default: 30)
|
section (default: 30)
|
||||||
{show_line} (boolean) show results text (default: true)
|
{show_line} (boolean) show results text (default: true)
|
||||||
@@ -1501,8 +1503,10 @@ builtin.lsp_definitions({opts}) *telescope.builtin.lsp_definitions()*
|
|||||||
{opts} (table) options to pass to the picker
|
{opts} (table) options to pass to the picker
|
||||||
|
|
||||||
Options: ~
|
Options: ~
|
||||||
{jump_type} (string) how to goto definition if there is only one,
|
{jump_type} (string) how to goto definition if there is only one
|
||||||
values: "tab", "split", "vsplit", "never"
|
and the definition file is different from the
|
||||||
|
current file, values: "tab", "split",
|
||||||
|
"vsplit", "never"
|
||||||
{fname_width} (number) defines the width of the filename section
|
{fname_width} (number) defines the width of the filename section
|
||||||
(default: 30)
|
(default: 30)
|
||||||
{show_line} (boolean) show results text (default: true)
|
{show_line} (boolean) show results text (default: true)
|
||||||
@@ -1518,8 +1522,10 @@ builtin.lsp_type_definitions({opts}) *telescope.builtin.lsp_type_definitions()*
|
|||||||
{opts} (table) options to pass to the picker
|
{opts} (table) options to pass to the picker
|
||||||
|
|
||||||
Options: ~
|
Options: ~
|
||||||
{jump_type} (string) how to goto definition if there is only one,
|
{jump_type} (string) how to goto definition if there is only one
|
||||||
values: "tab", "split", "vsplit", "never"
|
and the definition file is different from the
|
||||||
|
current file, values: "tab", "split",
|
||||||
|
"vsplit", "never"
|
||||||
{fname_width} (number) defines the width of the filename section
|
{fname_width} (number) defines the width of the filename section
|
||||||
(default: 30)
|
(default: 30)
|
||||||
{show_line} (boolean) show results text (default: true)
|
{show_line} (boolean) show results text (default: true)
|
||||||
@@ -1536,8 +1542,9 @@ builtin.lsp_implementations({opts}) *telescope.builtin.lsp_implementations()*
|
|||||||
|
|
||||||
Options: ~
|
Options: ~
|
||||||
{jump_type} (string) how to goto implementation if there is only
|
{jump_type} (string) how to goto implementation if there is only
|
||||||
one, values: "tab", "split", "vsplit",
|
one and the definition file is different from
|
||||||
"never"
|
the current file, values: "tab", "split",
|
||||||
|
"vsplit", "never"
|
||||||
{fname_width} (number) defines the width of the filename section
|
{fname_width} (number) defines the width of the filename section
|
||||||
(default: 30)
|
(default: 30)
|
||||||
{show_line} (boolean) show results text (default: true)
|
{show_line} (boolean) show results text (default: true)
|
||||||
|
|||||||
@@ -40,12 +40,14 @@ lsp.references = function(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if #locations == 1 and opts.jump_type ~= "never" then
|
if #locations == 1 and opts.jump_type ~= "never" then
|
||||||
if opts.jump_type == "tab" then
|
if filepath ~= locations[1].filename then
|
||||||
vim.cmd "tabedit"
|
if opts.jump_type == "tab" then
|
||||||
elseif opts.jump_type == "split" then
|
vim.cmd "tabedit"
|
||||||
vim.cmd "new"
|
elseif opts.jump_type == "split" then
|
||||||
elseif opts.jump_type == "vsplit" then
|
vim.cmd "new"
|
||||||
vim.cmd "vnew"
|
elseif opts.jump_type == "vsplit" then
|
||||||
|
vim.cmd "vnew"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-- jump to location
|
-- jump to location
|
||||||
local location = locations[1]
|
local location = locations[1]
|
||||||
@@ -184,12 +186,14 @@ local function list_or_jump(action, title, opts)
|
|||||||
if #flattened_results == 0 then
|
if #flattened_results == 0 then
|
||||||
return
|
return
|
||||||
elseif #flattened_results == 1 and opts.jump_type ~= "never" then
|
elseif #flattened_results == 1 and opts.jump_type ~= "never" then
|
||||||
if opts.jump_type == "tab" then
|
if params.textDocument.uri ~= flattened_results[1].uri then
|
||||||
vim.cmd "tabedit"
|
if opts.jump_type == "tab" then
|
||||||
elseif opts.jump_type == "split" then
|
vim.cmd "tabedit"
|
||||||
vim.cmd "new"
|
elseif opts.jump_type == "split" then
|
||||||
elseif opts.jump_type == "vsplit" then
|
vim.cmd "new"
|
||||||
vim.cmd "vnew"
|
elseif opts.jump_type == "vsplit" then
|
||||||
|
vim.cmd "vnew"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
vim.lsp.util.jump_to_location(flattened_results[1], offset_encoding)
|
vim.lsp.util.jump_to_location(flattened_results[1], offset_encoding)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ builtin.jumplist = require_on_exported_call("telescope.builtin.__internal").jump
|
|||||||
---@param opts table: options to pass to the picker
|
---@param opts table: options to pass to the picker
|
||||||
---@field include_declaration boolean: include symbol declaration in the lsp references (default: true)
|
---@field include_declaration boolean: include symbol declaration in the lsp references (default: true)
|
||||||
---@field include_current_line boolean: include current line (default: false)
|
---@field include_current_line boolean: include current line (default: false)
|
||||||
---@field jump_type string: how to goto reference if there is only one, values: "tab", "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", "split", "vsplit", "never"
|
||||||
---@field fname_width number: defines the width of the filename section (default: 30)
|
---@field fname_width number: defines the width of the filename section (default: 30)
|
||||||
---@field show_line boolean: show results text (default: true)
|
---@field show_line boolean: show results text (default: true)
|
||||||
---@field trim_text boolean: trim results text (default: false)
|
---@field trim_text boolean: trim results text (default: false)
|
||||||
@@ -401,7 +401,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
|
--- 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
|
---@param opts table: options to pass to the picker
|
||||||
---@field jump_type string: how to goto definition if there is only one, values: "tab", "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", "split", "vsplit", "never"
|
||||||
---@field fname_width number: defines the width of the filename section (default: 30)
|
---@field fname_width number: defines the width of the filename section (default: 30)
|
||||||
---@field show_line boolean: show results text (default: true)
|
---@field show_line boolean: show results text (default: true)
|
||||||
---@field trim_text boolean: trim results text (default: false)
|
---@field trim_text boolean: trim results text (default: false)
|
||||||
@@ -410,7 +410,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,
|
--- Goto the definition of the type of the word under the cursor, if there's only one,
|
||||||
--- otherwise show all options in Telescope
|
--- otherwise show all options in Telescope
|
||||||
---@param opts table: options to pass to the picker
|
---@param opts table: options to pass to the picker
|
||||||
---@field jump_type string: how to goto definition if there is only one, values: "tab", "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", "split", "vsplit", "never"
|
||||||
---@field fname_width number: defines the width of the filename section (default: 30)
|
---@field fname_width number: defines the width of the filename section (default: 30)
|
||||||
---@field show_line boolean: show results text (default: true)
|
---@field show_line boolean: show results text (default: true)
|
||||||
---@field trim_text boolean: trim results text (default: false)
|
---@field trim_text boolean: trim results text (default: false)
|
||||||
@@ -418,7 +418,7 @@ builtin.lsp_type_definitions = require("telescope.builtin.__lsp").type_definitio
|
|||||||
|
|
||||||
--- Goto the implementation of the word under the cursor if there's only one, otherwise show all options in Telescope
|
--- 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
|
---@param opts table: options to pass to the picker
|
||||||
---@field jump_type string: how to goto implementation if there is only one, values: "tab", "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", "split", "vsplit", "never"
|
||||||
---@field fname_width number: defines the width of the filename section (default: 30)
|
---@field fname_width number: defines the width of the filename section (default: 30)
|
||||||
---@field show_line boolean: show results text (default: true)
|
---@field show_line boolean: show results text (default: true)
|
||||||
---@field trim_text boolean: trim results text (default: false)
|
---@field trim_text boolean: trim results text (default: false)
|
||||||
|
|||||||
Reference in New Issue
Block a user