diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-03-01 23:31:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-01 23:31:20 +0000 |
commit | 39928a7f24916b35577864e28e505dda74103fb8 (patch) | |
tree | 8887b5622dd5edae62a53748cb226a684e8b26b4 /runtime/lua/vim/lsp/_watchfiles.lua | |
parent | a5fe8f59d98398d04bed8586cee73864bbcdde92 (diff) | |
parent | 4ff3217bbd8747d2d44680a825ac29097faf9c4b (diff) | |
download | rneovim-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.lua | 17 |
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 |