refactor(lsp): unify capability checks and registration #36781

Problem:
Our LSP type system didnt have a concept of RegistrationMethods, this is where the method to dynamically register for a capability is sent to a different method endpoint then is used to call it. Eg `textDocument/semanticTokens` rather than the specific full/range/delta methods

Solution:
Extended generator to create `vim.lsp.protocol.Methods.Registration` with these registration methods. Also extend `_request_name_to_client_capability` to cover these methods. Adjust typing to suit
This commit is contained in:
Tristan Knight
2025-12-06 23:31:11 +00:00
committed by GitHub
parent 4e1644d4d3
commit 9e9cdcaa18
6 changed files with 61 additions and 32 deletions

View File

@@ -1149,6 +1149,12 @@ protocol.Methods = {
workspace_workspaceFolders = 'workspace/workspaceFolders',
}
-- Generated by gen_lsp.lua, keep at end of file.
--- LSP registration methods
---@alias vim.lsp.protocol.Method.Registration
--- | 'notebookDocument/sync'
--- | 'textDocument/semanticTokens'
-- stylua: ignore start
-- Generated by gen_lsp.lua, keep at end of file.
--- Maps method names to the required client capability
@@ -1290,6 +1296,7 @@ protocol._request_name_to_server_capability = {
['workspace/willDeleteFiles'] = { 'workspace', 'fileOperations', 'willDelete' },
['workspace/willRenameFiles'] = { 'workspace', 'fileOperations', 'willRename' },
['workspace/workspaceFolders'] = { 'workspace', 'workspaceFolders' },
['textDocument/semanticTokens'] = { 'semanticTokensProvider' },
}
-- stylua: ignore end