commit dd3fa645735539c75b72dc1b0114278b5fa57f7f
parent f215a2aeaacb9635232cfad82de9a9674a86969c
Author: Folke Lemaitre <folke.lemaitre@gmail.com>
Date: Tue, 30 May 2023 19:15:07 +0200
fix(lsp): fix dynamic registration of code actions (#23826)
Diffstat:
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
@@ -681,9 +681,16 @@ local function on_code_action_results(results, ctx, options)
-- command: string
-- arguments?: any[]
--
+ ---@type lsp.Client
local client = vim.lsp.get_client_by_id(action_tuple[1])
local action = action_tuple[2]
- if not action.edit and client and client.supports_method('codeAction/resolve') then
+
+ local reg = client.dynamic_capabilities:get('textDocument/codeAction', { bufnr = ctx.bufnr })
+
+ local supports_resolve = vim.tbl_get(reg or {}, 'registerOptions', 'resolveProvider')
+ or client.supports_method('codeAction/resolve')
+
+ if not action.edit and client and supports_resolve then
client.request('codeAction/resolve', action, function(err, resolved_action)
if err then
vim.notify(err.code .. ': ' .. err.message, vim.log.levels.ERROR)