aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/buf.lua
diff options
context:
space:
mode:
authorMaria José Solano <majosolano99@gmail.com>2025-03-06 00:21:47 -0800
committerGitHub <noreply@github.com>2025-03-06 08:21:47 +0000
commit41b07b128ccbdc445c3a56618b0c6ec6ed0f3438 (patch)
tree68a238a3973f489da9987d404204eca78b43b778 /runtime/lua/vim/lsp/buf.lua
parent0c0352783fca7e9c56cd5ca8253834fee77c9d59 (diff)
downloadrneovim-41b07b128ccbdc445c3a56618b0c6ec6ed0f3438.tar.gz
rneovim-41b07b128ccbdc445c3a56618b0c6ec6ed0f3438.tar.bz2
rneovim-41b07b128ccbdc445c3a56618b0c6ec6ed0f3438.zip
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
Diffstat (limited to 'runtime/lua/vim/lsp/buf.lua')
-rw-r--r--runtime/lua/vim/lsp/buf.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index 47f41b43aa..094be17c83 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -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