commit 80d108eeee89c095e0c1226a558a690a708abaa1
parent cdc0974063fd18199040e783df5826af5786aee3
Author: tom-anders <13141438+tom-anders@users.noreply.github.com>
Date: Sat, 4 May 2024 10:04:47 +0200
refactor(lsp): use vim.cmd instead of api.nvim_command
As suggested in
https://github.com/neovim/neovim/pull/28483#discussion_r1586878457 and
https://github.com/neovim/neovim/pull/28483#discussion_r1586878226
Diffstat:
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
@@ -256,13 +256,13 @@ M[ms.textDocument_references] = function(_, result, ctx, config)
local list = { title = title, items = items, context = ctx }
if config.loclist then
vim.fn.setloclist(0, {}, ' ', list)
- api.nvim_command('lopen')
+ vim.cmd.lopen()
elseif config.on_list then
assert(vim.is_callable(config.on_list), 'on_list is not a function')
config.on_list(list)
else
vim.fn.setqflist({}, ' ', list)
- api.nvim_command('botright copen')
+ vim.cmd('botright copen')
end
end
@@ -290,13 +290,13 @@ local function response_to_list(map_result, entity, title_fn)
local list = { title = title, items = items, context = ctx }
if config.loclist then
vim.fn.setloclist(0, {}, ' ', list)
- api.nvim_command('lopen')
+ vim.cmd.lopen()
elseif config.on_list then
assert(vim.is_callable(config.on_list), 'on_list is not a function')
config.on_list(list)
else
vim.fn.setqflist({}, ' ', list)
- api.nvim_command('botright copen')
+ vim.cmd('botright copen')
end
end
end
@@ -447,7 +447,7 @@ local function location_handler(_, result, ctx, config)
return
end
vim.fn.setqflist({}, ' ', { title = title, items = items })
- api.nvim_command('botright copen')
+ vim.cmd('botright copen')
end
--- @see # https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_declaration
@@ -557,7 +557,7 @@ local function make_call_hierarchy_handler(direction)
end
end
vim.fn.setqflist({}, ' ', { title = 'LSP call hierarchy', items = items })
- api.nvim_command('botright copen')
+ vim.cmd('botright copen')
end
end
@@ -596,7 +596,7 @@ local function make_type_hierarchy_handler()
})
end
vim.fn.setqflist({}, ' ', { title = 'LSP type hierarchy', items = items })
- api.nvim_command('botright copen')
+ vim.cmd('botright copen')
end
end