Hi João,
Thanks for your interest in this issue and apologies for my slow replies.
> > I always figured the purpose of these watchers is
to account for switching git branches and the like, which is
functionality I appreciate, FWIW.
> I'm not sure I understand what you mean. In rust-analyzer, for
> example, it watches the Cargo file (similar to a Makefile) to
> know if you're adding new libraries to it, that the language
> server must link and compile. To know if a git branch has been
> switched, the server need to watch only one or two files under .git.
Sorry I wasn't very clear. The functionality I was alluding to is not specific to Git, it goes for any changes to project files that are not visited by buffers in Emacs.
Example:
- I have a single source file, "A", open in an Emacs buffer. The flycheck icon in my modeline is green, indicating no LSP errors in the buffer (I have lsp-mode/flycheck integration configured).
- Now, by some means outside Emacs -- a git or sed command, say -- I make a change to source file "B", which is not visited by an Emacs buffer, in such a way that there is now a type error in buffer "A" (maybe I've added a method to an interface).
- Momentarily, I see the flycheck icon in my modeline turn red.
I assume it's to support this kind of magic that lsp-mode watches so many files (all .ts files in the project, I believe).
However I just tried this with lsp-mode + rust-analyzer, and it doesn't seem to work there -- I have restart the server for the icon to turn red . But it does work with lsp-mode + typescript-language-server. So maybe it's the server watching the source files after all?
Best,
Elliott