aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/_watchfiles.lua
diff options
context:
space:
mode:
authorJon Huhn <nojnhuh@users.noreply.github.com>2023-05-20 00:45:39 -0500
committerGitHub <noreply@github.com>2023-05-20 07:45:39 +0200
commit073035a030f5ef8ae9b9ca51552f887944c52eaa (patch)
tree4e2baa579f8f0f9b89a47323f5e7d45aa632bc7c /runtime/lua/vim/lsp/_watchfiles.lua
parent413d57ae717d0e87ba01db7f46afaa5ae25ebe0b (diff)
downloadrneovim-073035a030f5ef8ae9b9ca51552f887944c52eaa.tar.gz
rneovim-073035a030f5ef8ae9b9ca51552f887944c52eaa.tar.bz2
rneovim-073035a030f5ef8ae9b9ca51552f887944c52eaa.zip
fix(lsp): don't register didChangeWatchedFiles when capability not set (#23689)
Some LSP servers (tailwindcss, rome) are known to request registration for `workspace/didChangeWatchedFiles` even when the corresponding client capability does not advertise support. This change adds an extra check in the `client/registerCapability` handler not to start a watch unless the client capability is set appropriately.
Diffstat (limited to 'runtime/lua/vim/lsp/_watchfiles.lua')
-rw-r--r--runtime/lua/vim/lsp/_watchfiles.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/_watchfiles.lua b/runtime/lua/vim/lsp/_watchfiles.lua
index 3a78724d79..cf2c57db1f 100644
--- a/runtime/lua/vim/lsp/_watchfiles.lua
+++ b/runtime/lua/vim/lsp/_watchfiles.lua
@@ -193,7 +193,12 @@ local to_lsp_change_type = {
function M.register(reg, ctx)
local client_id = ctx.client_id
local client = vim.lsp.get_client_by_id(client_id)
- if not client.workspace_folders then
+ 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
return
end
local watch_regs = {}