lsp-mode
lsp-mode copied to clipboard
file-notify-add-watch watch a directory doesn't work when backup file disabled or edit file in vscode?
Thank you for the bug report
- [X] I am using the latest version of
lsp-mode
related packages. - [X] I checked FAQ and Troubleshooting sections
- [ ] You may also try reproduce the issue using clean environment using the following command:
M-x lsp-start-plain
Bug description
I use doom-emacs and rust-analyzer, when edit the Cargo.toml
file in doom-emacs or vscode it will not trigger the workspace/didChangeWatchedFiles
event.
lsp-mode
use file-notify-add-watch
to watch a directory change to trigger workspace/didChangeWatchedFiles
.
It works in vanilla Emacs because it enabled backup file feature, when edit and save a file will trigger a create or rename or delete event . When disable this feature such as doom-emacs or edit the file in vscode, it only change the file content, only trigger a file change event, so directory change event will not work as expect.
Steps to reproduce
hlissner/doom-emacs#5630
brotzeit/rustic#322
When edit and save
Cargo.toml
file in doom-emacs and vscode, only file change event:
When edit in vanilla Emacs:
Expected behavior
When edit Cargo.toml
in vscode or emacs without backup file, can also reload rust-analyzer
Which Language Server did you use?
rust-analyzer
OS
MacOS
Error callstack
No response
Anything else?
No response
similar issue: #https://github.com/facebook/create-react-app/issues/9056
same here...
Running into this myself, on macOS. Maybe related to me using backup-by-copying t
that I learned from #3516 / #4112? Not sure.
It does seem less than ideal that file-notify-add-watch
can't detect changes to existing files, at least the way it's ending up working on macOS. There was some talk about improving in this bug but it was closed.
Is there something else lsp-mode could do? Would having (optional) support for using an external process for watching directories/files for changes help at all? At least then there would be a way to plug something in that can detect all creates/changes/deletes, I think.