fix: apply jump_type only if the definition file is different from the current file (#2324)

(cherry picked from commit 5d9658c39d)
This commit is contained in:
Luyu Huang
2023-02-19 20:32:37 +08:00
committed by Simon Hauser
parent 1c113b3e24
commit 48ece76315
4 changed files with 30 additions and 15 deletions
+8
View File
@@ -24,3 +24,11 @@ globals = {
read_globals = {
"vim",
}
files = {
["lua/telescope/builtin/init.lua"] = {
ignore = {
"631", -- allow line len > 120
}
},
}
+11 -6
View File
@@ -1467,8 +1467,10 @@ builtin.lsp_definitions({opts}) *telescope.builtin.lsp_definitions()*
{opts} (table) options to pass to the picker
Options: ~
{jump_type} (string) how to goto definition if there is only one,
values: "tab", "split", "vsplit", "never"
{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"
{fname_width} (number) defines the width of the filename section
(default: 30)
{show_line} (boolean) show results text (default: true)
@@ -1484,8 +1486,10 @@ builtin.lsp_type_definitions({opts}) *telescope.builtin.lsp_type_definitions()*
{opts} (table) options to pass to the picker
Options: ~
{jump_type} (string) how to goto definition if there is only one,
values: "tab", "split", "vsplit", "never"
{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"
{fname_width} (number) defines the width of the filename section
(default: 30)
{show_line} (boolean) show results text (default: true)
@@ -1502,8 +1506,9 @@ builtin.lsp_implementations({opts}) *telescope.builtin.lsp_implementations()*
Options: ~
{jump_type} (string) how to goto implementation if there is only
one, values: "tab", "split", "vsplit",
"never"
one 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
(default: 30)
{show_line} (boolean) show results text (default: true)
+8 -6
View File
@@ -165,12 +165,14 @@ local function list_or_jump(action, title, opts)
if #flattened_results == 0 then
return
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"
if params.textDocument.uri ~= flattened_results[1].uri 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
end
vim.lsp.util.jump_to_location(flattened_results[1], offset_encoding)
else
+3 -3
View File
@@ -393,7 +393,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, 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 show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)
@@ -402,7 +402,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, 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 show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)
@@ -410,7 +410,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
---@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 show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)