diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/lsp.txt | 3 | ||||
-rw-r--r-- | runtime/lua/vim/lsp.lua | 3 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/_watchfiles.lua | 15 |
3 files changed, 11 insertions, 10 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 1b35219bb8..da624dba65 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -988,8 +988,7 @@ start_client({config}) *vim.lsp.start_client()* passed to the language server on initialization. Hint: use make_client_capabilities() and modify its result. • Note: To send an empty dictionary use - `{[vim.type_idx]=vim.types.dictionary}`, else it will be - encoded as an array. + |vim.empty_dict()|, else it will be encoded as an array. • handlers: Map of language server method names to |lsp-handler| diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index b4c853d3d4..ea6b386b28 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -1027,8 +1027,7 @@ end --- \|vim.lsp.protocol.make_client_capabilities()|, passed to the language --- server on initialization. Hint: use make_client_capabilities() and modify --- its result. ---- - Note: To send an empty dictionary use ---- `{[vim.type_idx]=vim.types.dictionary}`, else it will be encoded as an +--- - Note: To send an empty dictionary use |vim.empty_dict()|, else it will be encoded as an --- array. --- --- - handlers: Map of language server method names to |lsp-handler| diff --git a/runtime/lua/vim/lsp/_watchfiles.lua b/runtime/lua/vim/lsp/_watchfiles.lua index c271dc6e14..5dbd4a7199 100644 --- a/runtime/lua/vim/lsp/_watchfiles.lua +++ b/runtime/lua/vim/lsp/_watchfiles.lua @@ -121,12 +121,15 @@ M._poll_exclude_pattern = parse('**/.git/{objects,subtree-cache}/**') function M.register(reg, ctx) local client_id = ctx.client_id local client = vim.lsp.get_client_by_id(client_id) - if - -- Ill-behaved servers may not honor the client capability and try to register - -- anyway, so ignore requests when the user has opted out of the feature. - not client.config.capabilities.workspace.didChangeWatchedFiles.dynamicRegistration - or not client.workspace_folders - then + -- Ill-behaved servers may not honor the client capability and try to register + -- anyway, so ignore requests when the user has opted out of the feature. + local has_capability = vim.tbl_get( + client.config.capabilities or {}, + 'workspace', + 'didChangeWatchedFiles', + 'dynamicRegistration' + ) + if not has_capability or not client.workspace_folders then return end local watch_regs = {} --- @type table<string,{pattern:userdata,kind:integer}> |