diff options
author | Maria José Solano <majosolano99@gmail.com> | 2024-05-14 07:08:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-14 07:08:13 -0700 |
commit | 6818ba271cb43b1430f019b832d7e26671e0f5f4 (patch) | |
tree | 0892e99883f9861c7a28309bd7c814e4e8acb63c | |
parent | abd2352bd8b896417af75ac85caad9a7f849841b (diff) | |
download | rneovim-6818ba271cb43b1430f019b832d7e26671e0f5f4.tar.gz rneovim-6818ba271cb43b1430f019b832d7e26671e0f5f4.tar.bz2 rneovim-6818ba271cb43b1430f019b832d7e26671e0f5f4.zip |
fix(health): clients may not support watchfiles #28710
-rw-r--r-- | runtime/lua/vim/lsp/health.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/health.lua b/runtime/lua/vim/lsp/health.lua index 797a1097f9..a79ae76eb9 100644 --- a/runtime/lua/vim/lsp/health.lua +++ b/runtime/lua/vim/lsp/health.lua @@ -51,6 +51,29 @@ end local function check_watcher() vim.health.start('vim.lsp: File watcher') + + -- Only run the check if file watching has been enabled by a client. + local clients = vim.lsp.get_clients() + if + --- @param client vim.lsp.Client + vim.iter(clients):all(function(client) + local has_capability = vim.tbl_get( + client.capabilities, + 'workspace', + 'didChangeWatchedFiles', + 'dynamicRegistration' + ) + local has_dynamic_capability = + client.dynamic_capabilities:get(vim.lsp.protocol.Methods.workspace_didChangeWatchedFiles) + return has_capability == nil + or has_dynamic_capability == nil + or client.workspace_folders == nil + end) + then + report_info('file watching "(workspace/didChangeWatchedFiles)" disabled on all clients') + return + end + local watchfunc = vim.lsp._watchfiles._watchfunc assert(watchfunc) local watchfunc_name --- @type string |