fix(lsp): fix dynamic registration of code actions (#23826)

This commit is contained in:
Folke Lemaitre 2023-05-30 19:15:07 +02:00 committed by GitHub
parent f215a2aeaa
commit dd3fa64573
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)