mirror of
https://github.com/neovim/neovim.git
synced 2025-11-03 09:14:24 +00:00
feat(lsp): use the meta model to generate server capability map
This commit is contained in:
@@ -38,55 +38,6 @@ lsp._resolve_to_request = {
|
||||
[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' },
|
||||
[ms.callHierarchy_outgoingCalls] = { 'callHierarchyProvider' },
|
||||
[ms.codeAction_resolve] = { 'codeActionProvider', 'resolveProvider' },
|
||||
[ms.codeLens_resolve] = { 'codeLensProvider', 'resolveProvider' },
|
||||
[ms.documentLink_resolve] = { 'documentLinkProvider', 'resolveProvider' },
|
||||
[ms.inlayHint_resolve] = { 'inlayHintProvider', 'resolveProvider' },
|
||||
[ms.textDocument_codeAction] = { 'codeActionProvider' },
|
||||
[ms.textDocument_codeLens] = { 'codeLensProvider' },
|
||||
[ms.textDocument_completion] = { 'completionProvider' },
|
||||
[ms.textDocument_declaration] = { 'declarationProvider' },
|
||||
[ms.textDocument_definition] = { 'definitionProvider' },
|
||||
[ms.textDocument_diagnostic] = { 'diagnosticProvider' },
|
||||
[ms.textDocument_didClose] = { 'textDocumentSync', 'openClose' },
|
||||
[ms.textDocument_didOpen] = { 'textDocumentSync', 'openClose' },
|
||||
[ms.textDocument_documentColor] = { 'colorProvider' },
|
||||
[ms.textDocument_documentHighlight] = { 'documentHighlightProvider' },
|
||||
[ms.textDocument_documentLink] = { 'documentLinkProvider' },
|
||||
[ms.textDocument_documentSymbol] = { 'documentSymbolProvider' },
|
||||
[ms.textDocument_foldingRange] = { 'foldingRangeProvider' },
|
||||
[ms.textDocument_formatting] = { 'documentFormattingProvider' },
|
||||
[ms.textDocument_hover] = { 'hoverProvider' },
|
||||
[ms.textDocument_implementation] = { 'implementationProvider' },
|
||||
[ms.textDocument_inlayHint] = { 'inlayHintProvider' },
|
||||
[ms.textDocument_inlineValue] = { 'inlineValueProvider' },
|
||||
[ms.textDocument_linkedEditingRange] = { 'linkedEditingRangeProvider' },
|
||||
[ms.textDocument_moniker] = { 'monikerProvider' },
|
||||
[ms.textDocument_onTypeFormatting] = { 'documentOnTypeFormattingProvider' },
|
||||
[ms.textDocument_prepareCallHierarchy] = { 'callHierarchyProvider' },
|
||||
[ms.textDocument_prepareRename] = { 'renameProvider', 'prepareProvider' },
|
||||
[ms.textDocument_prepareTypeHierarchy] = { 'typeHierarchyProvider' },
|
||||
[ms.textDocument_rangeFormatting] = { 'documentRangeFormattingProvider' },
|
||||
[ms.textDocument_rangesFormatting] = { 'documentRangeFormattingProvider', 'rangesSupport' },
|
||||
[ms.textDocument_references] = { 'referencesProvider' },
|
||||
[ms.textDocument_rename] = { 'renameProvider' },
|
||||
[ms.textDocument_selectionRange] = { 'selectionRangeProvider' },
|
||||
[ms.textDocument_semanticTokens_full] = { 'semanticTokensProvider' },
|
||||
[ms.textDocument_semanticTokens_full_delta] = { 'semanticTokensProvider' },
|
||||
[ms.textDocument_signatureHelp] = { 'signatureHelpProvider' },
|
||||
[ms.textDocument_typeDefinition] = { 'typeDefinitionProvider' },
|
||||
[ms.textDocument_willSaveWaitUntil] = { 'textDocumentSync', 'willSaveWaitUntil' },
|
||||
[ms.textDocument_willSave] = { 'textDocumentSync', 'willSave' },
|
||||
[ms.typeHierarchy_subtypes] = { 'typeHierarchyProvider' },
|
||||
[ms.typeHierarchy_supertypes] = { 'typeHierarchyProvider' },
|
||||
[ms.workspace_executeCommand] = { 'executeCommandProvider' },
|
||||
[ms.workspace_symbol] = { 'workspaceSymbolProvider' },
|
||||
}
|
||||
|
||||
-- TODO improve handling of scratch buffers with LSP attached.
|
||||
|
||||
---@private
|
||||
|
||||
@@ -1056,7 +1056,7 @@ function Client:supports_method(method, bufnr)
|
||||
--- @diagnostic disable-next-line:no-unknown
|
||||
bufnr = bufnr.bufnr
|
||||
end
|
||||
local required_capability = lsp._request_name_to_capability[method]
|
||||
local required_capability = lsp.protocol._request_name_to_capability[method]
|
||||
-- if we don't know about the method, assume that the client supports it.
|
||||
if not required_capability then
|
||||
return true
|
||||
|
||||
@@ -725,7 +725,6 @@ end
|
||||
--- | vim.lsp.protocol.Method.ServerToClient
|
||||
|
||||
-- Generated by gen_lsp.lua, keep at end of file.
|
||||
---
|
||||
--- @enum vim.lsp.protocol.Methods
|
||||
--- @see https://microsoft.github.io/language-server-protocol/specification/#metaModel
|
||||
--- LSP method names.
|
||||
@@ -1080,4 +1079,68 @@ protocol.Methods = {
|
||||
workspace_workspaceFolders = 'workspace/workspaceFolders',
|
||||
}
|
||||
|
||||
-- stylua: ignore start
|
||||
-- Generated by gen_lsp.lua, keep at end of file.
|
||||
--- Maps method names to the required server capability
|
||||
protocol._request_name_to_capability = {
|
||||
['codeAction/resolve'] = { 'codeActionProvider', 'resolveProvider' },
|
||||
['codeLens/resolve'] = { 'codeLensProvider', 'resolveProvider' },
|
||||
['completionItem/resolve'] = { 'completionProvider', 'resolveProvider' },
|
||||
['documentLink/resolve'] = { 'documentLinkProvider', 'resolveProvider' },
|
||||
['inlayHint/resolve'] = { 'inlayHintProvider', 'resolveProvider' },
|
||||
['textDocument/codeAction'] = { 'codeActionProvider' },
|
||||
['textDocument/codeLens'] = { 'codeLensProvider' },
|
||||
['textDocument/completion'] = { 'completionProvider' },
|
||||
['textDocument/declaration'] = { 'declarationProvider' },
|
||||
['textDocument/definition'] = { 'definitionProvider' },
|
||||
['textDocument/diagnostic'] = { 'diagnosticProvider' },
|
||||
['textDocument/didChange'] = { 'textDocumentSync' },
|
||||
['textDocument/didClose'] = { 'textDocumentSync', 'openClose' },
|
||||
['textDocument/didOpen'] = { 'textDocumentSync', 'openClose' },
|
||||
['textDocument/didSave'] = { 'textDocumentSync', 'save' },
|
||||
['textDocument/documentColor'] = { 'colorProvider' },
|
||||
['textDocument/documentHighlight'] = { 'documentHighlightProvider' },
|
||||
['textDocument/documentLink'] = { 'documentLinkProvider' },
|
||||
['textDocument/documentSymbol'] = { 'documentSymbolProvider' },
|
||||
['textDocument/foldingRange'] = { 'foldingRangeProvider' },
|
||||
['textDocument/formatting'] = { 'documentFormattingProvider' },
|
||||
['textDocument/hover'] = { 'hoverProvider' },
|
||||
['textDocument/implementation'] = { 'implementationProvider' },
|
||||
['textDocument/inlayHint'] = { 'inlayHintProvider' },
|
||||
['textDocument/inlineCompletion'] = { 'inlineCompletionProvider' },
|
||||
['textDocument/inlineValue'] = { 'inlineValueProvider' },
|
||||
['textDocument/linkedEditingRange'] = { 'linkedEditingRangeProvider' },
|
||||
['textDocument/moniker'] = { 'monikerProvider' },
|
||||
['textDocument/onTypeFormatting'] = { 'documentOnTypeFormattingProvider' },
|
||||
['textDocument/prepareCallHierarchy'] = { 'callHierarchyProvider' },
|
||||
['textDocument/prepareRename'] = { 'renameProvider', 'prepareProvider' },
|
||||
['textDocument/prepareTypeHierarchy'] = { 'typeHierarchyProvider' },
|
||||
['textDocument/rangeFormatting'] = { 'documentRangeFormattingProvider' },
|
||||
['textDocument/rangesFormatting'] = { 'documentRangeFormattingProvider', 'rangesSupport' },
|
||||
['textDocument/references'] = { 'referencesProvider' },
|
||||
['textDocument/rename'] = { 'renameProvider' },
|
||||
['textDocument/selectionRange'] = { 'selectionRangeProvider' },
|
||||
['textDocument/semanticTokens/full'] = { 'semanticTokensProvider' },
|
||||
['textDocument/semanticTokens/full/delta'] = { 'semanticTokensProvider', 'full', 'delta' },
|
||||
['textDocument/semanticTokens/range'] = { 'semanticTokensProvider', 'range' },
|
||||
['textDocument/signatureHelp'] = { 'signatureHelpProvider' },
|
||||
['textDocument/typeDefinition'] = { 'typeDefinitionProvider' },
|
||||
['textDocument/willSave'] = { 'textDocumentSync', 'willSave' },
|
||||
['textDocument/willSaveWaitUntil'] = { 'textDocumentSync', 'willSaveWaitUntil' },
|
||||
['workspaceSymbol/resolve'] = { 'workspaceSymbolProvider', 'resolveProvider' },
|
||||
['workspace/diagnostic'] = { 'diagnosticProvider', 'workspaceDiagnostics' },
|
||||
['workspace/didChangeWorkspaceFolders'] = { 'workspace', 'workspaceFolders', 'changeNotifications' },
|
||||
['workspace/didCreateFiles'] = { 'workspace', 'fileOperations', 'didCreate' },
|
||||
['workspace/didDeleteFiles'] = { 'workspace', 'fileOperations', 'didDelete' },
|
||||
['workspace/didRenameFiles'] = { 'workspace', 'fileOperations', 'didRename' },
|
||||
['workspace/executeCommand'] = { 'executeCommandProvider' },
|
||||
['workspace/symbol'] = { 'workspaceSymbolProvider' },
|
||||
['workspace/textDocumentContent'] = { 'workspace', 'textDocumentContent' },
|
||||
['workspace/willCreateFiles'] = { 'workspace', 'fileOperations', 'willCreate' },
|
||||
['workspace/willDeleteFiles'] = { 'workspace', 'fileOperations', 'willDelete' },
|
||||
['workspace/willRenameFiles'] = { 'workspace', 'fileOperations', 'willRename' },
|
||||
['workspace/workspaceFolders'] = { 'workspace', 'workspaceFolders' },
|
||||
}
|
||||
-- stylua: ignore end
|
||||
|
||||
return protocol
|
||||
|
||||
Reference in New Issue
Block a user