diff options
author | Lewis Russell <lewis6991@gmail.com> | 2022-05-18 20:03:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-18 21:03:24 +0200 |
commit | 3eea66d65a75c83cbd6bd7ec2aa0886781c807c9 (patch) | |
tree | ecaef2738b6550e485cd83b633d79dfd5458527c /runtime/lua/vim/lsp/handlers.lua | |
parent | 03a8269e3a904e7660eb95b9c17ccfc0938f1e30 (diff) | |
download | rneovim-3eea66d65a75c83cbd6bd7ec2aa0886781c807c9.tar.gz rneovim-3eea66d65a75c83cbd6bd7ec2aa0886781c807c9.tar.bz2 rneovim-3eea66d65a75c83cbd6bd7ec2aa0886781c807c9.zip |
feat(lsp): option to reuse_win for jump actions (#18577)
Diffstat (limited to 'runtime/lua/vim/lsp/handlers.lua')
-rw-r--r-- | runtime/lua/vim/lsp/handlers.lua | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index b3a253c118..61cc89dcac 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -327,18 +327,20 @@ M['textDocument/hover'] = M.hover ---@param result (table) result of LSP method; a location or a list of locations. ---@param ctx (table) table containing the context of the request, including the method ---(`textDocument/definition` can return `Location` or `Location[]` -local function location_handler(_, result, ctx, _) +local function location_handler(_, result, ctx, config) if result == nil or vim.tbl_isempty(result) then local _ = log.info() and log.info(ctx.method, 'No location found') return nil end local client = 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 vim.tbl_islist(result) then - util.jump_to_location(result[1], client.offset_encoding) + util.jump_to_location(result[1], client.offset_encoding, config.reuse_win) if #result > 1 then vim.fn.setqflist({}, ' ', { @@ -348,7 +350,7 @@ local function location_handler(_, result, ctx, _) api.nvim_command('botright copen') end else - util.jump_to_location(result, client.offset_encoding) + util.jump_to_location(result, client.offset_encoding, config.reuse_win) end end |