mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
feat(lsp): support for resolving code action command (#32704)
* fix(lsp): don't call codeAction_resolve with commands * feat(lsp): support for resolving code action command
This commit is contained in:
committed by
GitHub
parent
0c0352783f
commit
41b07b128c
@ -1129,6 +1129,7 @@ local function on_code_action_results(results, opts)
|
||||
if not choice then
|
||||
return
|
||||
end
|
||||
|
||||
-- textDocument/codeAction can return either Command[] or CodeAction[]
|
||||
--
|
||||
-- CodeAction
|
||||
@ -1140,12 +1141,18 @@ local function on_code_action_results(results, opts)
|
||||
-- title: string
|
||||
-- command: string
|
||||
-- arguments?: any[]
|
||||
--
|
||||
|
||||
local client = assert(lsp.get_client_by_id(choice.ctx.client_id))
|
||||
local action = choice.action
|
||||
local bufnr = assert(choice.ctx.bufnr, 'Must have buffer number')
|
||||
|
||||
if not action.edit and client:supports_method(ms.codeAction_resolve) then
|
||||
-- Only code actions are resolved, so if we have a command, just apply it.
|
||||
if type(action.title) == 'string' and type(action.command) == 'string' then
|
||||
apply_action(action, client, choice.ctx)
|
||||
return
|
||||
end
|
||||
|
||||
if not action.edit or not action.command and client:supports_method(ms.codeAction_resolve) then
|
||||
client:request(ms.codeAction_resolve, action, function(err, resolved_action)
|
||||
if err then
|
||||
if action.command then
|
||||
|
Reference in New Issue
Block a user