From dd3fa645735539c75b72dc1b0114278b5fa57f7f Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 30 May 2023 19:15:07 +0200 Subject: [PATCH] fix(lsp): fix dynamic registration of code actions (#23826) --- runtime/lua/vim/lsp/buf.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index b2f202c4ba..bb3ca0e6d6 100644 --- 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)