Herr Bischoff

Neovim: LSP Extremely Slow With tsserver

Neovim’s built-in language server implementation is slow as molasses with tsserver using a default setup. Even a simple “go to definition” took up to a minute. I found it quicker and more efficient to just use *. After this frustrating experience while working on a JavaScript code base, I just found a solution. You have to configure a root folder like this:

  root_dir = require('lspconfig.util').root_pattern('.git')

The above example will find your Git repository root and start the server there. Otherwise, for some inexplicable reason, it appears to start this server in the current user’s home folder. You can verify this with :LspInfo. As one server instance per recursively found package.json is started, you quickly run out of resources and the LSP functionality slows down to a crawl. With the root folder set, it operates almost as quick as inside VScode or when using Coc.