summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/_watch.lua
AgeCommit message (Collapse)AuthorFiles
2026-02-23fix(watch): invalid joined path #37973Oleksandr Chekhovskyi1
Problem: When vim._watch.watch() is used to watch a single file, libuv returns the basename as the filename argument in the callback. The code joins this with the watched path, producing a nonsensical path like "/path/to/file.lua/file.lua", which causes ENOTDIR errors on subsequent fs_stat calls. Solution: Check whether the watched path is a directory before joining the filename. When watching a file, ignore the filename from libuv and use the watched path directly.
2025-09-15fix(lua): don't leak timer when vim._watch.watch() fails (#35768)zeertzjq1
This fixes the following warning in tests with ASAN or TSAN: -------- Running tests from test/functional/lua/watch_spec.lua RUN T4253 vim._watch watch() ignores nonexistent paths: 29.00 ms OK nvim took 2006 milliseconds to exit after last test This indicates a likely problem with the test even if it passed!
2024-10-21feat(vim.validate): improve fast form and deprecate spec formLewis Russell1
Problem: `vim.validate()` takes two forms when it only needs one. Solution: - Teach the fast form all the features of the spec form. - Deprecate the spec form. - General optimizations for both forms. - Add a `message` argument which can be used alongside or in place of the `optional` argument.
2024-10-17perf(validate): use lighter versionLewis Russell1
- Also fix `vim.validate()` for PUC Lua when showing errors for values that aren't string or number.
2024-10-02fix(watch): ignore nonexistent paths (ENOENT)Justin M. Keyes1
Problem: The `_watch.watch()` strategy may fail if the given path does not exist: …/vim/_watch.lua:101: ENOENT: no such file or directory stack traceback: [C]: in function 'assert' …/vim/_watch.lua:101: in function <…/vim/_watch.lua:61> [string "<nvim>"]:5: in main chunk - `_watch.watch()` actively asserts any error returned by `handle:start()`. - whereas `_watch.watchdirs()` just ignores the result of `root_handle:start()`. Servers may send "client/registerCapability" with "workspace/didChangeWatchedFiles" item(s) (`baseUri`) which do not actually exist on the filesystem: https://github.com/neovim/neovim/issues/28058#issuecomment-2189929424 { method = "client/registerCapability", params = { registrations = { { method = "workspace/didChangeWatchedFiles", registerOptions = { watchers = { { globPattern = { baseUri = "file:///Users/does/not/exist", pattern = "**/*.{ts,js,mts,mjs,cjs,cts,json,svelte}" } }, ... } Solution: - Remove the assert in `_watch.watch()`. - Show a once-only message for both cases. - More detailed logging is blocked until we have `nvim_log` / `vim.log`. fix #28058
2024-08-01fix(watch): exclude .git when using inotifywait (#29914)Manuel1
inotifywait man page specifies: The file must be specified with a relative or absolute path according to whether a relative or absolute path is given for watched directories. So it would only work this way in case the path is relative (which at least for gopls it is not)
2024-07-06feat(lsp): drop fswatch, use inotifywait (#29374)Andreas Schneider1
This patch replaces fswatch with inotifywait from inotify-toools: https://github.com/inotify-tools/inotify-tools fswatch takes ~1min to set up recursively for the Samba source code directory. inotifywait needs less than a second to do the same thing. https://github.com/emcrisostomo/fswatch/issues/321 Also it fswatch seems to be unmaintained in the meantime. Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2024-05-14perf(lsp): only joinpath for dirs in watchdirsMathias Fussenegger1
Doesn't have a huge impact, but showed up in profile output using `require("jit.p").start("i1", "/tmp/profile")` before: 31% joinpath 25% fs.lua:0 13% normalize 13% skip 8% _watchfunc 5% gsplit 3% spairs after: 34% skip 29% fs.lua:0 12% joinpath 7% normalize 5% _watchfunc 5% spairs
2024-03-12fix: move fswatch linux check inside of vim.schedule (#27824)Tomas Slusny1
Fixes issue reported in the original PR: https://github.com/neovim/neovim/pull/27810 Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
2024-03-11docs: adjust fswatch overflow message to mention docs with infoTomas Slusny1
- Add :h fswatch-limitations that notifies user about default inotify limitations on linux and how to adjust them - Check for Event queue overflow message from fswatch and refer user to new documentation Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
2024-03-10fix(fswatch): --latency is locale dependentOscar Creator1
2024-03-06feat(lsp): report fswatch errorsLewis Russell1
Resolves #27713 Co-authored-by: Tomasz N <przepompownia@users.noreply.github.com>
2024-03-01feat(lsp): add fswatch watchfunc backendLewis Russell1
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.
2024-03-01refactor(watch): simplify filechanges processingLewis Russell1
2024-03-01refactor(watch): general tidy upLewis Russell1
- Rename watch.poll to watch.watchdirs - Unify how include and exclude is applied - Improve type hints
2023-12-30refactor: fix luals warningsdundargoc1
2023-11-21perf(lsp): use async fs_stat for file watching on linux (#26123)Mathias Fußenegger1
2023-11-19perf(lsp): replace file polling on linux with per dir watcher (#26108)Mathias Fußenegger1
Should help with https://github.com/neovim/neovim/issues/23291 On linux `new_fs_event` doesn't support recursive watching, but we can still use it to watch folders. The downside of this approach is that we may end up sending some false `Deleted` events. For example, if you save a file named `foo` there will be a intermediate `foo~` due to the save mechanism of neovim. The events we get from vim.uv in that case are: - rename: foo~ - rename: foo~ - rename: foo - rename: foo - change: foo - change: foo The mechanism in this PR uses a debounce to reduce this to: - deleted: foo~ - changed: foo `foo~` will be the false positive. I suspect that for the LSP case this is good enough. If not, we may need to follow up on this and keep a table in memory that tracks available files.
2023-08-09fix(lua): improve annotations for stricter luals diagnostics (#24609)Christian Clason1
Problem: luals returns stricter diagnostics with bundled luarc.json Solution: Improve some function and type annotations: * use recognized uv.* types * disable diagnostic for global `vim` in shared.lua * docs: don't start comment lines with taglink (otherwise LuaLS will interpret it as a type) * add type alias for lpeg pattern * fix return annotation for `vim.secure.trust` * rename local Range object in vim.version (shadows `Range` in vim.treesitter) * fix some "missing fields" warnings * add missing required fields for test functions in eval.lua * rename lsp meta files for consistency
2023-07-18docs(lua): more improvements (#24387)Lewis Russell1
* docs(lua): teach lua2dox how to table * docs(lua): teach gen_vimdoc.py about local functions No more need to mark local functions with @private * docs(lua): mention @nodoc and @meta in dev-lua-doc * fixup! Co-authored-by: Justin M. Keyes <justinkz@gmail.com> --------- Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2023-07-10fix(lint): lint warnings #24226Raphael1
2023-06-14perf(lsp): reduce polling handles for workspace/didChangeWatchedFiles (#23500)Jon Huhn1
Co-authored-by: Lewis Russell <lewis6991@gmail.com>
2023-06-03feat(lua): rename vim.loop -> vim.uv (#22846)Lewis Russell1
2023-04-17fix(watchfiles): skip Created events when poll starts (#23139)Jon Huhn1
2023-03-05feat(lsp): implement workspace/didChangeWatchedFiles (#22405)Jon Huhn1
2023-02-25Revert "feat(lsp): implement workspace/didChangeWatchedFiles (#21293)"Mathias Fussenegger1
This reverts commit 5732aa706c639b3d775573d91d1139f24624629c. Causes editor to freeze in projects with many watcher registrations
2023-02-25feat(lsp): implement workspace/didChangeWatchedFiles (#21293)Jon Huhn1