With lsp-mode, I'm getting

Watching all the files in /foo would require adding watches to 3792 directories, so watching the repo may slow Emacs down.
Do you want to watch all files in /foo? (y or n) n

How can I set maximum or how can I disable being asked this question?;) f

  • You'll just have to try it: the limit will depend on a host of factors, in particular the "heft" of your machine, but it may also depend on the complexity of your directory tree. I would answer y and see how bad it is: it may not be bad at all. If it is, then I would bisect to try to find the sweet spot: use 2048 (about half) - if that's bad, halve it again; if it's OK, try 3/2*2048 - and so on. Be systematic.
    – NickD
    Dec 12, 2023 at 15:06
  • Right, but one can say if 5000 directories is overkill. Also, how can I change the number once I've set a number?;) Dec 12, 2023 at 15:12
  • "one can say if 5000 directories is overkill" - not without testing. On the other question, no idea.
    – NickD
    Dec 12, 2023 at 15:21
  • It depends on the platform as well: on some a file descriptor is consumed for every file watched, on some it's one for every directory, and on some it's zero.
    – rpluim
    Dec 12, 2023 at 15:35
  • Can someone at least provide hints on the easiest way to recover if things bog down? Do I just need to close the files involved? Or stop some processes? or ?? I'm on Ubuntu 22.04 with 32 GB RAM, FWIW.
    – nealmcb
    Dec 31, 2023 at 23:23

1 Answer 1


My pleasure;)

(setq lsp-file-watch-threshold 5000)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.