mirror of
https://github.com/neovim/neovim.git
synced 2025-12-12 09:32:39 +00:00
feat(lsp): generate method to client capability map
This commit is contained in:
@@ -1069,7 +1069,7 @@ function Client:supports_method(method, bufnr)
|
|||||||
--- @diagnostic disable-next-line:no-unknown
|
--- @diagnostic disable-next-line:no-unknown
|
||||||
bufnr = bufnr.bufnr
|
bufnr = bufnr.bufnr
|
||||||
end
|
end
|
||||||
local required_capability = lsp.protocol._request_name_to_capability[method]
|
local required_capability = lsp.protocol._request_name_to_server_capability[method]
|
||||||
-- if we don't know about the method, assume that the client supports it.
|
-- if we don't know about the method, assume that the client supports it.
|
||||||
if not required_capability then
|
if not required_capability then
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -1092,10 +1092,88 @@ protocol.Methods = {
|
|||||||
workspace_workspaceFolders = 'workspace/workspaceFolders',
|
workspace_workspaceFolders = 'workspace/workspaceFolders',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- 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/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' },
|
||||||
|
['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' },
|
||||||
|
}
|
||||||
|
-- stylua: ignore end
|
||||||
|
|
||||||
-- stylua: ignore start
|
-- stylua: ignore start
|
||||||
-- Generated by gen_lsp.lua, keep at end of file.
|
-- Generated by gen_lsp.lua, keep at end of file.
|
||||||
--- Maps method names to the required server capability
|
--- Maps method names to the required server capability
|
||||||
protocol._request_name_to_capability = {
|
protocol._request_name_to_server_capability = {
|
||||||
['codeAction/resolve'] = { 'codeActionProvider', 'resolveProvider' },
|
['codeAction/resolve'] = { 'codeActionProvider', 'resolveProvider' },
|
||||||
['codeLens/resolve'] = { 'codeLensProvider', 'resolveProvider' },
|
['codeLens/resolve'] = { 'codeLensProvider', 'resolveProvider' },
|
||||||
['completionItem/resolve'] = { 'completionProvider', 'resolveProvider' },
|
['completionItem/resolve'] = { 'completionProvider', 'resolveProvider' },
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Generates lua-ls annotations for lsp.
|
|||||||
Also updates types in runtime/lua/vim/lsp/protocol.lua
|
Also updates types in runtime/lua/vim/lsp/protocol.lua
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
src/gen/gen_lsp.lua [options]
|
nvim -l src/gen/gen_lsp.lua [options]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--version <version> LSP version to use (default: 3.18)
|
--version <version> LSP version to use (default: 3.18)
|
||||||
@@ -198,12 +198,32 @@ local function write_to_vim_protocol(protocol)
|
|||||||
end
|
end
|
||||||
|
|
||||||
do -- capabilities
|
do -- capabilities
|
||||||
|
vim.list_extend(output, {
|
||||||
|
'',
|
||||||
|
'-- 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 = {',
|
||||||
|
})
|
||||||
|
|
||||||
|
for _, item in ipairs(all) do
|
||||||
|
if item.clientCapability then
|
||||||
|
output[#output + 1] = (" ['%s'] = { %s },"):format(
|
||||||
|
item.method,
|
||||||
|
"'" .. item.clientCapability:gsub('%.', "', '") .. "'"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
output[#output + 1] = '}'
|
||||||
|
output[#output + 1] = '-- stylua: ignore end'
|
||||||
|
|
||||||
vim.list_extend(output, {
|
vim.list_extend(output, {
|
||||||
'',
|
'',
|
||||||
'-- stylua: ignore start',
|
'-- stylua: ignore start',
|
||||||
'-- Generated by gen_lsp.lua, keep at end of file.',
|
'-- Generated by gen_lsp.lua, keep at end of file.',
|
||||||
'--- Maps method names to the required server capability',
|
'--- Maps method names to the required server capability',
|
||||||
'protocol._request_name_to_capability = {',
|
'protocol._request_name_to_server_capability = {',
|
||||||
})
|
})
|
||||||
|
|
||||||
for _, item in ipairs(all) do
|
for _, item in ipairs(all) do
|
||||||
|
|||||||
Reference in New Issue
Block a user