aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/buf.lua
diff options
context:
space:
mode:
authorEvgeni Chasnovski <evgeni.chasnovski@gmail.com>2023-10-31 14:18:44 +0200
committerGitHub <noreply@github.com>2023-10-31 13:18:44 +0100
commitadbe7f368397da21465f27181e254dd3694820e9 (patch)
treee57b7448ff156a3a0a9a3a12d31ce9605c7bbd8e /runtime/lua/vim/lsp/buf.lua
parentc1a93285d25be8c832eceecc440e6128b773dc01 (diff)
downloadrneovim-adbe7f368397da21465f27181e254dd3694820e9.tar.gz
rneovim-adbe7f368397da21465f27181e254dd3694820e9.tar.bz2
rneovim-adbe7f368397da21465f27181e254dd3694820e9.zip
fix(lsp): call `on_list()` even for single location (#25830)
Problem: Currently there is no way of customizing behavior of `declaration`, `definition`, `typeDefinition`, and `implementation` methods in `vim.lsp.buf` when LSP server returns `Location`. Instead, cursor jumps to that location directly. Solution: Normalize LSP response to be `Location[]` for those four cases.
Diffstat (limited to 'runtime/lua/vim/lsp/buf.lua')
-rw-r--r--runtime/lua/vim/lsp/buf.lua12
1 files changed, 8 insertions, 4 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index 9436fbbf56..b9b7aefae6 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -62,7 +62,8 @@ end
---
---@param options table|nil additional options
--- - reuse_win: (boolean) Jump to existing window if buffer is already open.
---- - on_list: (function) handler for list results. See |lsp-on-list-handler|
+--- - on_list: (function) |lsp-on-list-handler| replacing the default handler.
+--- Called for any non-empty result.
function M.declaration(options)
local params = util.make_position_params()
request_with_options(ms.textDocument_declaration, params, options)
@@ -72,7 +73,8 @@ end
---
---@param options table|nil additional options
--- - reuse_win: (boolean) Jump to existing window if buffer is already open.
---- - on_list: (function) handler for list results. See |lsp-on-list-handler|
+--- - on_list: (function) |lsp-on-list-handler| replacing the default handler.
+--- Called for any non-empty result.
function M.definition(options)
local params = util.make_position_params()
request_with_options(ms.textDocument_definition, params, options)
@@ -82,7 +84,8 @@ end
---
---@param options table|nil additional options
--- - reuse_win: (boolean) Jump to existing window if buffer is already open.
---- - on_list: (function) handler for list results. See |lsp-on-list-handler|
+--- - on_list: (function) |lsp-on-list-handler| replacing the default handler.
+--- Called for any non-empty result.
function M.type_definition(options)
local params = util.make_position_params()
request_with_options(ms.textDocument_typeDefinition, params, options)
@@ -92,7 +95,8 @@ end
--- quickfix window.
---
---@param options table|nil additional options
---- - on_list: (function) handler for list results. See |lsp-on-list-handler|
+--- - on_list: (function) |lsp-on-list-handler| replacing the default handler.
+--- Called for any non-empty result.
function M.implementation(options)
local params = util.make_position_params()
request_with_options(ms.textDocument_implementation, params, options)