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

How use root project tsc version when open vim in sub directory ? #422

Open apoutchika opened 1 year ago

apoutchika commented 1 year ago

Hello,

In my project I am using TSC 5.0.2. This version is well used when I open vim in the root of my project.

But, when I open vim in a subdirectory (ex: cd src/ && vim), coc-tsserver uses TSC 4.9.5.

How do I tell coc-tsserver to find the root of the project (first parent package.json ?) and use the correct version of typescript?

Thanks in advance

tatethurston commented 1 year ago

Related: https://github.com/neoclide/coc-tsserver/issues/409.

I believe setting tsserver.useLocalTsdk will achieve what you want.

apoutchika commented 1 year ago

thank you for your reply :+1:

useLocalTsdk is already set to true... This is my :CocConfig :

{
  "suggest.noselect": false,
  "coc.preferences.formatOnType": true,
  "coc.preferences.formatOnSave": true,
  "eslint.autoFixOnSave": true,
  "javascript.suggestionActions.enabled": true,

  "tsserver.useLocalTsdk": true,
  "tsserver.locale": "fr",

  "css.validate": false,
  "less.validate": false,
  "scss.validate": false,

  "stylelintplus.autoFixOnFormat": true,
  "stylelintplus.autoFixOnSave": true,
  "stylelintplus.cssInJs": true,
  "stylelintplus.validateOnSave": true,
  "stylelintplus.enable": true,

  "javascript.preferences.importModuleSpecifier": "shortest",
  "typescript.preferences.importModuleSpecifier": "shortest"
}

In my package.json, the devDependencies typescript version is 5.0.2

When i open it in the root, next to the package.json file, the version of typescript is 5.0.2, but when i open vim in subdirection, like src, the version is 4.9.5...

Did I forget a configuration somewhere ?

Thank you