aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authortom-anders <13141438+tom-anders@users.noreply.github.com>2024-05-04 09:58:07 +0200
committertom-anders <13141438+tom-anders@users.noreply.github.com>2024-05-07 20:20:35 +0200
commit6ffc209a8a84c6d627dde39d27283d98a451b105 (patch)
treec73da83ed8ea04a8bbda541e2f55172526b5f1d0 /runtime/lua/vim
parent3da251efc6329c4d5e6b94780815dce8d6e24999 (diff)
downloadrneovim-6ffc209a8a84c6d627dde39d27283d98a451b105.tar.gz
rneovim-6ffc209a8a84c6d627dde39d27283d98a451b105.tar.bz2
rneovim-6ffc209a8a84c6d627dde39d27283d98a451b105.zip
refactor(lsp): move repeated table construction into a variable
As suggested in https://github.com/neovim/neovim/pull/28483#discussion_r1581712828
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/lsp/handlers.lua14
1 files changed, 8 insertions, 6 deletions
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
index 11818b6a89..de146ab1ef 100644
--- a/runtime/lua/vim/lsp/handlers.lua
+++ b/runtime/lua/vim/lsp/handlers.lua
@@ -253,14 +253,15 @@ M[ms.textDocument_references] = function(_, result, ctx, config)
local title = 'References'
local items = util.locations_to_items(result, client.offset_encoding)
+ local list = { title = title, items = items, context = ctx }
if config.loclist then
- vim.fn.setloclist(0, {}, ' ', { title = title, items = items, context = ctx })
+ vim.fn.setloclist(0, {}, ' ', list)
api.nvim_command('lopen')
elseif config.on_list then
assert(vim.is_callable(config.on_list), 'on_list is not a function')
- config.on_list({ title = title, items = items, context = ctx })
+ config.on_list(list)
else
- vim.fn.setqflist({}, ' ', { title = title, items = items, context = ctx })
+ vim.fn.setqflist({}, ' ', list)
api.nvim_command('botright copen')
end
end
@@ -286,14 +287,15 @@ local function response_to_list(map_result, entity, title_fn)
local title = title_fn(ctx)
local items = map_result(result, ctx.bufnr)
+ local list = { title = title, items = items, context = ctx }
if config.loclist then
- vim.fn.setloclist(0, {}, ' ', { title = title, items = items, context = ctx })
+ vim.fn.setloclist(0, {}, ' ', list)
api.nvim_command('lopen')
elseif config.on_list then
assert(vim.is_callable(config.on_list), 'on_list is not a function')
- config.on_list({ title = title, items = items, context = ctx })
+ config.on_list(list)
else
- vim.fn.setqflist({}, ' ', { title = title, items = items, context = ctx })
+ vim.fn.setqflist({}, ' ', list)
api.nvim_command('botright copen')
end
end