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

@ -3,7 +3,6 @@ local validate = vim.validate
local lsp = vim._defer_require('vim.lsp', {
_changetracking = ..., --- @module 'vim.lsp._changetracking'
_dynamic = ..., --- @module 'vim.lsp._dynamic'
_snippet_grammar = ..., --- @module 'vim.lsp._snippet_grammar'
_tagfunc = ..., --- @module 'vim.lsp._tagfunc'
_watchfiles = ..., --- @module 'vim.lsp._watchfiles'
@ -31,6 +30,13 @@ local changetracking = lsp._changetracking
---@nodoc
lsp.rpc_response_error = lsp.rpc.rpc_response_error
lsp._resolve_to_request = {
[ms.codeAction_resolve] = ms.textDocument_codeAction,
[ms.codeLens_resolve] = ms.textDocument_codeLens,
[ms.documentLink_resolve] = ms.textDocument_documentLink,
[ms.inlayHint_resolve] = ms.textDocument_inlayHint,
}
-- maps request name to the required server_capability in the client.
lsp._request_name_to_capability = {
[ms.callHierarchy_incomingCalls] = { 'callHierarchyProvider' },