mirror of
https://github.com/neovim/neovim.git
synced 2026-02-19 09:58:32 +00:00
refactor(lsp): centralize provider capability resolution #37221
- Refactor LSP client to use unified provider-based capability lookup for diagnostics and other features. - Introduce `_provider_value_get` to abstract capability retrieval, supporting both static and dynamic registrations. - Update diagnostic handling and protocol mappings to leverage provider-centric logic.
This commit is contained in:
@@ -613,6 +613,15 @@ function protocol.make_client_capabilities()
|
||||
diagnostics = {
|
||||
refreshSupport = true,
|
||||
},
|
||||
fileOperations = {
|
||||
dynamicRegistration = false,
|
||||
didCreate = false,
|
||||
willCreate = false,
|
||||
didRename = false,
|
||||
willRename = false,
|
||||
didDelete = false,
|
||||
willDelete = false,
|
||||
},
|
||||
},
|
||||
experimental = nil,
|
||||
window = {
|
||||
@@ -1160,79 +1169,49 @@ protocol.Methods = {
|
||||
-- stylua: ignore start
|
||||
-- Generated by gen_lsp.lua, keep at end of file.
|
||||
--- Maps method names to the required client capability
|
||||
protocol._request_name_to_client_capability = {
|
||||
['codeAction/resolve'] = { 'textDocument', 'codeAction', 'resolveSupport' },
|
||||
['codeLens/resolve'] = { 'textDocument', 'codeLens', 'resolveSupport' },
|
||||
['completionItem/resolve'] = { 'textDocument', 'completion', 'completionItem', 'resolveSupport' },
|
||||
['documentLink/resolve'] = { 'textDocument', 'documentLink' },
|
||||
['inlayHint/resolve'] = { 'textDocument', 'inlayHint', 'resolveSupport' },
|
||||
['textDocument/codeAction'] = { 'textDocument', 'codeAction' },
|
||||
['textDocument/codeLens'] = { 'textDocument', 'codeLens' },
|
||||
['textDocument/colorPresentation'] = { 'textDocument', 'colorProvider' },
|
||||
['textDocument/completion'] = { 'textDocument', 'completion' },
|
||||
['textDocument/declaration'] = { 'textDocument', 'declaration' },
|
||||
['textDocument/definition'] = { 'textDocument', 'definition' },
|
||||
['textDocument/diagnostic'] = { 'textDocument', 'diagnostic' },
|
||||
['textDocument/didChange'] = { 'textDocument', 'synchronization' },
|
||||
['textDocument/didClose'] = { 'textDocument', 'synchronization' },
|
||||
['textDocument/didOpen'] = { 'textDocument', 'synchronization' },
|
||||
['textDocument/didSave'] = { 'textDocument', 'synchronization', 'didSave' },
|
||||
['textDocument/documentColor'] = { 'textDocument', 'colorProvider' },
|
||||
['textDocument/documentHighlight'] = { 'textDocument', 'documentHighlight' },
|
||||
['textDocument/documentLink'] = { 'textDocument', 'documentLink' },
|
||||
['textDocument/documentSymbol'] = { 'textDocument', 'documentSymbol' },
|
||||
['textDocument/foldingRange'] = { 'textDocument', 'foldingRange' },
|
||||
['textDocument/formatting'] = { 'textDocument', 'formatting' },
|
||||
['textDocument/hover'] = { 'textDocument', 'hover' },
|
||||
['textDocument/implementation'] = { 'textDocument', 'implementation' },
|
||||
['textDocument/inlayHint'] = { 'textDocument', 'inlayHint' },
|
||||
['textDocument/inlineCompletion'] = { 'textDocument', 'inlineCompletion' },
|
||||
['textDocument/inlineValue'] = { 'textDocument', 'inlineValue' },
|
||||
['textDocument/linkedEditingRange'] = { 'textDocument', 'linkedEditingRange' },
|
||||
['textDocument/moniker'] = { 'textDocument', 'moniker' },
|
||||
['textDocument/onTypeFormatting'] = { 'textDocument', 'onTypeFormatting' },
|
||||
['textDocument/prepareCallHierarchy'] = { 'textDocument', 'callHierarchy' },
|
||||
['textDocument/prepareRename'] = { 'textDocument', 'rename', 'prepareSupport' },
|
||||
['textDocument/prepareTypeHierarchy'] = { 'textDocument', 'typeHierarchy' },
|
||||
['textDocument/publishDiagnostics'] = { 'textDocument', 'publishDiagnostics' },
|
||||
['textDocument/rangeFormatting'] = { 'textDocument', 'rangeFormatting' },
|
||||
['textDocument/rangesFormatting'] = { 'textDocument', 'rangeFormatting', 'rangesSupport' },
|
||||
['textDocument/references'] = { 'textDocument', 'references' },
|
||||
['textDocument/rename'] = { 'textDocument', 'rename' },
|
||||
['textDocument/selectionRange'] = { 'textDocument', 'selectionRange' },
|
||||
['textDocument/semanticTokens/full'] = { 'textDocument', 'semanticTokens' },
|
||||
['textDocument/semanticTokens/full/delta'] = { 'textDocument', 'semanticTokens', 'requests', 'full', 'delta' },
|
||||
['textDocument/semanticTokens/range'] = { 'textDocument', 'semanticTokens', 'requests', 'range' },
|
||||
['textDocument/signatureHelp'] = { 'textDocument', 'signatureHelp' },
|
||||
['textDocument/typeDefinition'] = { 'textDocument', 'typeDefinition' },
|
||||
['textDocument/willSave'] = { 'textDocument', 'synchronization', 'willSave' },
|
||||
['textDocument/willSaveWaitUntil'] = { 'textDocument', 'synchronization', 'willSaveWaitUntil' },
|
||||
['window/showDocument'] = { 'window', 'showDocument', 'support' },
|
||||
['window/showMessage'] = { 'window', 'showMessage' },
|
||||
['window/showMessageRequest'] = { 'window', 'showMessage' },
|
||||
['window/workDoneProgress/create'] = { 'window', 'workDoneProgress' },
|
||||
['workspaceSymbol/resolve'] = { 'workspace', 'symbol', 'resolveSupport' },
|
||||
['workspace/applyEdit'] = { 'workspace', 'applyEdit' },
|
||||
['workspace/codeLens/refresh'] = { 'workspace', 'codeLens' },
|
||||
['workspace/configuration'] = { 'workspace', 'configuration' },
|
||||
['workspace/diagnostic'] = { 'workspace', 'diagnostics' },
|
||||
['workspace/diagnostic/refresh'] = { 'workspace', 'diagnostics', 'refreshSupport' },
|
||||
---TODO: also has workspace/* items because spec lacks a top-level "workspaceProvider"
|
||||
protocol._provider_to_client_registration = {
|
||||
['callHierarchyProvider'] = { 'textDocument', 'callHierarchy' },
|
||||
['codeActionProvider'] = { 'textDocument', 'codeAction' },
|
||||
['codeLensProvider'] = { 'textDocument', 'codeLens' },
|
||||
['colorProvider'] = { 'textDocument', 'colorProvider' },
|
||||
['completionProvider'] = { 'textDocument', 'completion' },
|
||||
['declarationProvider'] = { 'textDocument', 'declaration' },
|
||||
['definitionProvider'] = { 'textDocument', 'definition' },
|
||||
['diagnosticProvider'] = { 'textDocument', 'diagnostic' },
|
||||
['documentFormattingProvider'] = { 'textDocument', 'formatting' },
|
||||
['documentHighlightProvider'] = { 'textDocument', 'documentHighlight' },
|
||||
['documentLinkProvider'] = { 'textDocument', 'documentLink' },
|
||||
['documentOnTypeFormattingProvider'] = { 'textDocument', 'onTypeFormatting' },
|
||||
['documentRangeFormattingProvider'] = { 'textDocument', 'rangeFormatting' },
|
||||
['documentSymbolProvider'] = { 'textDocument', 'documentSymbol' },
|
||||
['executeCommandProvider'] = { 'workspace', 'executeCommand' },
|
||||
['foldingRangeProvider'] = { 'textDocument', 'foldingRange' },
|
||||
['hoverProvider'] = { 'textDocument', 'hover' },
|
||||
['implementationProvider'] = { 'textDocument', 'implementation' },
|
||||
['inlayHintProvider'] = { 'textDocument', 'inlayHint' },
|
||||
['inlineCompletionProvider'] = { 'textDocument', 'inlineCompletion' },
|
||||
['inlineValueProvider'] = { 'textDocument', 'inlineValue' },
|
||||
['linkedEditingRangeProvider'] = { 'textDocument', 'linkedEditingRange' },
|
||||
['monikerProvider'] = { 'textDocument', 'moniker' },
|
||||
['referencesProvider'] = { 'textDocument', 'references' },
|
||||
['renameProvider'] = { 'textDocument', 'rename' },
|
||||
['selectionRangeProvider'] = { 'textDocument', 'selectionRange' },
|
||||
['semanticTokensProvider'] = { 'textDocument', 'semanticTokens' },
|
||||
['signatureHelpProvider'] = { 'textDocument', 'signatureHelp' },
|
||||
['textDocumentSync'] = { 'textDocument', 'synchronization' },
|
||||
['typeDefinitionProvider'] = { 'textDocument', 'typeDefinition' },
|
||||
['typeHierarchyProvider'] = { 'textDocument', 'typeHierarchy' },
|
||||
['workspace/didChangeConfiguration'] = { 'workspace', 'didChangeConfiguration' },
|
||||
['workspace/didChangeWatchedFiles'] = { 'workspace', 'didChangeWatchedFiles' },
|
||||
['workspace/didCreateFiles'] = { 'workspace', 'fileOperations', 'didCreate' },
|
||||
['workspace/didDeleteFiles'] = { 'workspace', 'fileOperations', 'didDelete' },
|
||||
['workspace/didRenameFiles'] = { 'workspace', 'fileOperations', 'didRename' },
|
||||
['workspace/executeCommand'] = { 'workspace', 'executeCommand' },
|
||||
['workspace/foldingRange/refresh'] = { 'workspace', 'foldingRange', 'refreshSupport' },
|
||||
['workspace/inlayHint/refresh'] = { 'workspace', 'inlayHint', 'refreshSupport' },
|
||||
['workspace/inlineValue/refresh'] = { 'workspace', 'inlineValue', 'refreshSupport' },
|
||||
['workspace/semanticTokens/refresh'] = { 'workspace', 'semanticTokens', 'refreshSupport' },
|
||||
['workspace/symbol'] = { 'workspace', 'symbol' },
|
||||
['workspace/textDocumentContent'] = { 'workspace', 'textDocumentContent' },
|
||||
['workspace/willCreateFiles'] = { 'workspace', 'fileOperations', 'willCreate' },
|
||||
['workspace/willDeleteFiles'] = { 'workspace', 'fileOperations', 'willDelete' },
|
||||
['workspace/willRenameFiles'] = { 'workspace', 'fileOperations', 'willRename' },
|
||||
['workspace/workspaceFolders'] = { 'workspace', 'workspaceFolders' },
|
||||
['workspaceSymbolProvider'] = { 'workspace', 'symbol' },
|
||||
}
|
||||
-- stylua: ignore end
|
||||
|
||||
@@ -1299,13 +1278,13 @@ protocol._request_name_to_server_capability = {
|
||||
['workspace/willRenameFiles'] = { 'workspace', 'fileOperations', 'willRename' },
|
||||
['workspace/workspaceFolders'] = { 'workspace', 'workspaceFolders' },
|
||||
['textDocument/semanticTokens'] = { 'semanticTokensProvider' },
|
||||
['workspace/didChangeWatchedFiles'] = { 'workspace/didChangeWatchedFiles' },
|
||||
}
|
||||
-- stylua: ignore end
|
||||
|
||||
-- stylua: ignore start
|
||||
-- Generated by gen_lsp.lua, keep at end of file.
|
||||
--- Maps method names to the required client capability
|
||||
protocol._request_name_allows_registration = {
|
||||
protocol._method_supports_dynamic_registration = {
|
||||
['notebookDocument/didChange'] = true,
|
||||
['notebookDocument/didClose'] = true,
|
||||
['notebookDocument/didOpen'] = true,
|
||||
@@ -1351,6 +1330,7 @@ protocol._request_name_allows_registration = {
|
||||
['textDocument/willSaveWaitUntil'] = true,
|
||||
['workspace/didChangeConfiguration'] = true,
|
||||
['workspace/didChangeWatchedFiles'] = true,
|
||||
['workspace/didChangeWorkspaceFolders'] = true,
|
||||
['workspace/didCreateFiles'] = true,
|
||||
['workspace/didDeleteFiles'] = true,
|
||||
['workspace/didRenameFiles'] = true,
|
||||
@@ -1363,4 +1343,51 @@ protocol._request_name_allows_registration = {
|
||||
}
|
||||
-- stylua: ignore end
|
||||
|
||||
-- stylua: ignore start
|
||||
-- Generated by gen_lsp.lua, keep at end of file.
|
||||
protocol._method_supports_static_registration = {
|
||||
['textDocument/codeAction'] = true,
|
||||
['textDocument/codeLens'] = true,
|
||||
['textDocument/colorPresentation'] = true,
|
||||
['textDocument/completion'] = true,
|
||||
['textDocument/declaration'] = true,
|
||||
['textDocument/definition'] = true,
|
||||
['textDocument/diagnostic'] = true,
|
||||
['textDocument/didChange'] = true,
|
||||
['textDocument/documentColor'] = true,
|
||||
['textDocument/documentHighlight'] = true,
|
||||
['textDocument/documentLink'] = true,
|
||||
['textDocument/documentSymbol'] = true,
|
||||
['textDocument/foldingRange'] = true,
|
||||
['textDocument/formatting'] = true,
|
||||
['textDocument/hover'] = true,
|
||||
['textDocument/implementation'] = true,
|
||||
['textDocument/inlayHint'] = true,
|
||||
['textDocument/inlineCompletion'] = true,
|
||||
['textDocument/inlineValue'] = true,
|
||||
['textDocument/linkedEditingRange'] = true,
|
||||
['textDocument/moniker'] = true,
|
||||
['textDocument/onTypeFormatting'] = true,
|
||||
['textDocument/prepareCallHierarchy'] = true,
|
||||
['textDocument/prepareTypeHierarchy'] = true,
|
||||
['textDocument/rangeFormatting'] = true,
|
||||
['textDocument/references'] = true,
|
||||
['textDocument/rename'] = true,
|
||||
['textDocument/selectionRange'] = true,
|
||||
['textDocument/semanticTokens/full'] = true,
|
||||
['textDocument/signatureHelp'] = true,
|
||||
['textDocument/typeDefinition'] = true,
|
||||
['workspace/executeCommand'] = true,
|
||||
['workspace/symbol'] = true,
|
||||
}
|
||||
-- stylua: ignore end
|
||||
|
||||
-- stylua: ignore start
|
||||
-- Generated by gen_lsp.lua, keep at end of file.
|
||||
-- These methods have no registration options but can still be registered dynamically.
|
||||
protocol._methods_with_no_registration_options = {
|
||||
['workspace/didChangeWorkspaceFolders'] = true ,
|
||||
}
|
||||
-- stylua: ignore end
|
||||
|
||||
return protocol
|
||||
|
||||
Reference in New Issue
Block a user