Buffer is sometimes attached to tsserver with the wrong root_dir when using a mono repo #1437
Unanswered
darcyparker
asked this question in
Q&A
Replies: 1 comment
-
|
To help debug, I added: and I am getting the expected |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a mono repo (typescript, with workspaces).
The project's
package.jsonhas:The project has a
tsconfig.base.jsonand it'stsconfig.jsonextends it.As well, each package has its own
tsconfig.jsonthat extends the../../tsconfig.base.jsonand addscomposite: truein thecompilerOptions.After upgrading to typescript 5.1.6 (from 4.x), I started having problems with this mono repo. I feel it is something to do with nvim and my nvim configuration, because the issues do not occur with vscode. It also seems to be something new with moving to typescript 5.x.
If I do a fresh start of nvim and the first buffer I open is in one of the packages, then the lsp client (tsserver) the buffer attaches to has the correct
root_dirset toproject/packages/<packagename>. Then if the second buffer I open is in/src, a second lsp client (tsserver) is started with the correctroot_dirset toproject. In this case, everything is good... The types are all available and I cango to definitioncorrectly from each buffer.But, if I start fresh, and open a file in
/src, and then open another buffer (for example with go to definition) that is in one of theproject/packages, there is only 1 LSP client that the 2 buffers are attached to. I think they should be separate clients, because the buffer for theproject/packages/<packagename>can't resolve its types properly... and it seems to be reading the wrongtsconfig.json.I want nvim to create a new lsp client when needed with the correct root_dir so that it can resolve the modules correctly. What can I do to ensure the correct root_dir is set when a buffer is opened?
Beta Was this translation helpful? Give feedback.
All reactions