diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2024-10-20 23:40:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-20 23:40:44 +0200 |
commit | 0083e03d6fa7586d0d6360b40b52b0cab0d2e7ba (patch) | |
tree | 4b81b12101025632701174e6de58d9079bf90064 /runtime/lua/vim/lsp/handlers.lua | |
parent | 9b8907d90508d7b66f025bbd1f5a48a78c5ce035 (diff) | |
download | rneovim-0083e03d6fa7586d0d6360b40b52b0cab0d2e7ba.tar.gz rneovim-0083e03d6fa7586d0d6360b40b52b0cab0d2e7ba.tar.bz2 rneovim-0083e03d6fa7586d0d6360b40b52b0cab0d2e7ba.zip |
feat(lsp)!: support multiple clients in goto methods (#30877)
Relates to:
- https://github.com/neovim/neovim/issues/30034
- https://github.com/neovim/neovim/issues/17712
- https://github.com/neovim/neovim/issues/16363
Closes:
- https://github.com/neovim/neovim/issues/26936 (but only provides bufnr
and method)
- https://github.com/neovim/neovim/issues/22318
Might fix: https://github.com/neovim/neovim/issues/30737
Diffstat (limited to 'runtime/lua/vim/lsp/handlers.lua')
-rw-r--r-- | runtime/lua/vim/lsp/handlers.lua | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index 3306e480dd..c87cf94b98 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -386,57 +386,6 @@ end --- @see # https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_hover M[ms.textDocument_hover] = M.hover ---- Jumps to a location. Used as a handler for multiple LSP methods. ----@param _ nil not used ----@param result (table) result of LSP method; a location or a list of locations. ----@param ctx (lsp.HandlerContext) table containing the context of the request, including the method ----@param config? vim.lsp.LocationOpts ----(`textDocument/definition` can return `Location` or `Location[]` -local function location_handler(_, result, ctx, config) - if result == nil or vim.tbl_isempty(result) then - log.info(ctx.method, 'No location found') - return nil - end - local client = assert(vim.lsp.get_client_by_id(ctx.client_id)) - - config = config or {} - - -- textDocument/definition can return Location or Location[] - -- https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition - if not vim.islist(result) then - result = { result } - end - - local title = 'LSP locations' - local items = util.locations_to_items(result, client.offset_encoding) - - if config.on_list then - assert(vim.is_callable(config.on_list), 'on_list is not a function') - config.on_list({ title = title, items = items }) - return - end - if #result == 1 then - util.jump_to_location(result[1], client.offset_encoding, config.reuse_win) - return - end - if config.loclist then - vim.fn.setloclist(0, {}, ' ', { title = title, items = items }) - vim.cmd.lopen() - else - vim.fn.setqflist({}, ' ', { title = title, items = items }) - vim.cmd('botright copen') - end -end - ---- @see # https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_declaration -M[ms.textDocument_declaration] = location_handler ---- @see # https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition -M[ms.textDocument_definition] = location_handler ---- @see # https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_typeDefinition -M[ms.textDocument_typeDefinition] = location_handler ---- @see # https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_implementation -M[ms.textDocument_implementation] = location_handler - local sig_help_ns = api.nvim_create_namespace('vim_lsp_signature_help') --- |lsp-handler| for the method "textDocument/signatureHelp". |