Slow LSP on large TS monorepo project. Caching?

Hi All,
I’m trying to switch from VS Code to neovim with LSP.
I’m working on a large monorepo Typescript project.
I have configured LSP as in the github, and everything works, but every time I open a file in a package it takes about a minute before I’m able to use LSP’s go to definition.
In VS Code only there’s only initial delay, but after it loads everything navigation is smooth.
It seems like neovim starts new TS server every time I switch to a different package within my monorepo. This results in a large delay before I’m able to navigate.

Is this something configurable? I have enough RAM and disk space to enable heavy caching if needed.
I was determined to switch but this thing is just unbearable.

Thanks!

The default root_dir for tsserver spawns one instance per package.json. You can override that with something like:

require('lspconfig').tsserver.setup({
  root_dir = require('lspconfig.util').root_pattern('.git')
})

That will find your repository root (assuming you’re using git) and start the server there. Alternatively you can make it start at your current working dir or whatever you want really, just set root_dir to a custom function.

2 Likes

Thanks @fsouza! I’ll try that