== Common Issues/Fixes

=== File watches

Some language servers request file notifications from Emacs using
https://microsoft.github.io/language-server-protocol/specification#workspace_didChangeWatchedFiles[`workspace/didChangeWatchedFiles`],
in which case `lsp-mode` will monitor every file in the path recursively for
changes. If your project contains a large number of files, this might slow
`lsp-mode` down. In this case, you can either disable file notifications entirely
via <<lsp-enable-file-watchers,`lsp-enable-file-watchers`>>, or disable it
for a specific project using https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html[Directory Variables].

=== Frequent freezes/stuttering

`lsp-mode` in Emacs versions < 27 uses the
https://github.com/emacs-mirror/emacs/blob/master/lisp/json.el[json.el] library
bundled with Emacs to parse and encode JSON objects in order to communicate
with a language server. When working with large objects, this can create a
significant garbage collection overhead which slows down Emacs significantly.
This can be either fixed by setting `gc-cons-threshold` to a large enough value
(like `30000000`, causing it to start a garbage collection cycle on every
30 MB of allocated memory), or using Emacs 27 compiled with native JSON support
(`--with-json`).

If you're using company-lsp, setting
https://github.com/tigersoldier/company-lsp#customization[`company-lsp-cache-candidates`]
to either `'auto` or `t` can help reduce freezes when performing code completion.
