refactor(lsp): fold in dynamic_registration code into the client

Problem:

Capability register logic is spread across 3 files.

Solution:

- Consolidate (and simplify) logic into the client.
- Teach client.supports_method about resolve methods
This commit is contained in:
Lewis Russell
2024-11-05 17:34:21 +00:00
committed by Lewis Russell
parent e2ad251c8d
commit 989a37a594
7 changed files with 188 additions and 189 deletions

View File

@@ -1131,12 +1131,7 @@ local function on_code_action_results(results, opts)
local action = choice.action
local bufnr = assert(choice.ctx.bufnr, 'Must have buffer number')
local reg = client.dynamic_capabilities:get(ms.textDocument_codeAction, { bufnr = bufnr })
local supports_resolve = vim.tbl_get(reg or {}, 'registerOptions', 'resolveProvider')
or client.supports_method(ms.codeAction_resolve)
if not action.edit and client and supports_resolve then
if not action.edit 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