Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lsp-jump-type): tab drop as new jump_type option for go-to LSP pickers #2751

Merged
merged 4 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions doc/telescope.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1549,8 +1549,8 @@ builtin.lsp_references({opts}) *telescope.builtin.lsp_references()*
{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"
values: "tab", "tab drop", "split",
"vsplit", "never"
{fname_width} (number) defines the width of the filename
section (default: 30)
{show_line} (boolean) show results text (default: true)
Expand Down Expand Up @@ -1601,8 +1601,8 @@ builtin.lsp_definitions({opts}) *telescope.builtin.lsp_definitions()*
Options: ~
{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"
the current file, values: "tab", "tab
drop", "split", "vsplit", "never"
{fname_width} (number) defines the width of the filename section
(default: 30)
{show_line} (boolean) show results text (default: true)
Expand All @@ -1623,8 +1623,8 @@ builtin.lsp_type_definitions({opts}) *telescope.builtin.lsp_type_definitions()*
Options: ~
{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"
the current file, values: "tab", "tab
drop", "split", "vsplit", "never"
{fname_width} (number) defines the width of the filename section
(default: 30)
{show_line} (boolean) show results text (default: true)
Expand All @@ -1645,8 +1645,8 @@ builtin.lsp_implementations({opts}) *telescope.builtin.lsp_implementations()*
Options: ~
{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"
from the current file, values: "tab", "tab
drop", "split", "vsplit", "never"
{fname_width} (number) defines the width of the filename section
(default: 30)
{show_line} (boolean) show results text (default: true)
Expand Down
5 changes: 5 additions & 0 deletions lua/telescope/builtin/__lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ lsp.references = function(opts)
vim.cmd "new"
elseif opts.jump_type == "vsplit" then
vim.cmd "vnew"
elseif opts.jump_type == "tab drop" then
vim.cmd("tab drop " .. locations[1].filename)
end
end
-- jump to location
Expand Down Expand Up @@ -197,6 +199,9 @@ local function list_or_jump(action, title, opts)
vim.cmd "new"
elseif opts.jump_type == "vsplit" then
vim.cmd "vnew"
elseif opts.jump_type == "tab drop" then
local file_path = vim.uri_to_fname(flattened_results[1].uri)
vim.cmd("tab drop " .. file_path)
end
end

Expand Down
8 changes: 4 additions & 4 deletions lua/telescope/builtin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,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", "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"
---@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)
Expand All @@ -441,7 +441,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", "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"
---@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)
Expand All @@ -452,7 +452,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", "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"
---@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)
Expand All @@ -462,7 +462,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", "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"
---@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)
Expand Down