neoclide / coc-tsserver

Tsserver extension for coc.nvim that provide rich features like VSCode for javascript & typescript
MIT License
1.05k stars 68 forks source link

Should load tsserver from main workspace on restart #306

Closed javier-garcia-meteologica closed 2 years ago

javier-garcia-meteologica commented 3 years ago

I work in a main project that uses typescript 4.3. After ocasionally browsing through other projects, coc-nvim accumulates workspaces, as described here. Then if I call :CocRestart, coc-tsserver loads instead the tsserver from another project, which uses typescript 4.0.

coc-tsserver doesn't care which tsserver gets loaded, but in this case it's important. The main project uses typescript 4.3 because it uses rxjs which exports type definitions using package.json#typesVersions and this feature is only supported in typescript 4.2+.

https://github.com/neoclide/coc-tsserver/blob/66ae279b1a3441ad5ca77d47934f99f039cd1e0b/src/server/utils/versionProvider.ts#L109-L121

I've tried to close all buffers from other workspaces and then delete the workspaces in CocList folders, but they still re-appear after :CocRestart. I even tried let g:WorkspaceFolders = [].

chemzqm commented 3 years ago

Could coc-tserver start a separate instance of tsserver for each workspace?

No need for that since tsserver can support multiple folders.

Seems we should prefer workspace folder of current buffer to avoid this issue.