feat(lsp): add fswatch watchfunc backend

Problem:
  vim._watch.watchdirs has terrible performance.

Solution:
  - On linux use fswatch as a watcher backend if available.

  - Add File watcher section to health:vim.lsp. Warn if watchfunc is
    libuv-poll.
This commit is contained in:
Lewis Russell
2024-02-07 11:28:35 +00:00
parent 816b56f878
commit 4ff3217bbd
7 changed files with 140 additions and 11 deletions

View File

@@ -21,6 +21,15 @@ describe('vim._watch', function()
local function run(watchfunc)
it('detects file changes (watchfunc=' .. watchfunc .. '())', function()
if watchfunc == 'fswatch' then
skip(is_os('mac'), 'flaky test on mac')
skip(
not is_ci() and helpers.fn.executable('fswatch') == 0,
'fswatch not installed and not on CI'
)
skip(is_os('win'), 'not supported on windows')
end
if watchfunc == 'watch' then
skip(is_os('bsd'), 'Stopped working on bsd after 3ca967387c49c754561c3b11a574797504d40f38')
else
@@ -95,6 +104,7 @@ describe('vim._watch', function()
vim.uv.sleep(100)
touch(watched_path)
vim.uv.sleep(100)
os.remove(watched_path)
vim.uv.sleep(100)
@@ -113,5 +123,5 @@ describe('vim._watch', function()
run('watch')
run('watchdirs')
run('fswatch')
end)