aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/_watchfiles.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-03-01 23:31:20 +0000
committerGitHub <noreply@github.com>2024-03-01 23:31:20 +0000
commit39928a7f24916b35577864e28e505dda74103fb8 (patch)
tree8887b5622dd5edae62a53748cb226a684e8b26b4 /runtime/lua/vim/lsp/_watchfiles.lua
parenta5fe8f59d98398d04bed8586cee73864bbcdde92 (diff)
parent4ff3217bbd8747d2d44680a825ac29097faf9c4b (diff)
downloadrneovim-39928a7f24916b35577864e28e505dda74103fb8.tar.gz
rneovim-39928a7f24916b35577864e28e505dda74103fb8.tar.bz2
rneovim-39928a7f24916b35577864e28e505dda74103fb8.zip
Merge pull request #27347 from lewis6991/fswatch
feat(lsp): add fswatch watchfunc backend
Diffstat (limited to 'runtime/lua/vim/lsp/_watchfiles.lua')
-rw-r--r--runtime/lua/vim/lsp/_watchfiles.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/_watchfiles.lua b/runtime/lua/vim/lsp/_watchfiles.lua
index 6ca60b78cd..49328fbe9b 100644
--- a/runtime/lua/vim/lsp/_watchfiles.lua
+++ b/runtime/lua/vim/lsp/_watchfiles.lua
@@ -7,7 +7,13 @@ local lpeg = vim.lpeg
local M = {}
-M._watchfunc = (vim.fn.has('win32') == 1 or vim.fn.has('mac') == 1) and watch.watch or watch.poll
+if vim.fn.has('win32') == 1 or vim.fn.has('mac') == 1 then
+ M._watchfunc = watch.watch
+elseif vim.fn.executable('fswatch') == 1 then
+ M._watchfunc = watch.fswatch
+else
+ M._watchfunc = watch.watchdirs
+end
---@type table<integer, table<string, function[]>> client id -> registration id -> cancel function
local cancels = vim.defaulttable()
@@ -163,4 +169,13 @@ function M.unregister(unreg, ctx)
end
end
+--- @param client_id integer
+function M.cancel(client_id)
+ for _, reg_cancels in pairs(cancels[client_id]) do
+ for _, cancel in pairs(reg_cancels) do
+ cancel()
+ end
+ end
+end
+
return M