neoclide / coc-tsserver

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

Completion/suggestions not working for TS files (but work for JS files) #236

Closed gaylonalfano closed 3 years ago

gaylonalfano commented 3 years ago

Hello - Thank you for this fantastic tool/extension! I'm having some odd behavior when working with basic JS/TS projects. Some projects work just fine, then other times only the .js files will get code suggestions (all seeming to come from coc-tsserver extension).

I realize this is vague, so I've created a simple project where I have a main.ts file and a corresponding main.js file in the project directory. I do not have a tsconfig.json file in place (though I have tried adding one, but with no luck). Below are the logs. I even updated my global TS using npm install -g typescript@latest and updated coc-tsserver to the latest version (4.1.2).

CocInfo ``` ## versions vim version: NVIM v0.4.3 node version: v12.18.3 coc.nvim version: 0.0.79-5a9a0f22a2 coc.nvim directory: /Users/gaylonalfano/.config/nvim/plugged/coc.nvim term: iTerm.app platform: darwin ## Log of coc.nvim 2020-12-06T15:22:06.153 INFO (pid:4406) [services] - registered service "eslint" 2020-12-06T15:22:06.155 INFO (pid:4406) [services] - eslint langserver state change: stopped => starting 2020-12-06T15:22:06.180 INFO (pid:4406) [language-client-index] - eslint started with 4411 2020-12-06T15:22:06.204 INFO (pid:4406) [services] - registered service "highlight" 2020-12-06T15:22:06.211 INFO (pid:4406) [language-client-index] - highlight started with 4412 2020-12-06T15:22:06.373 INFO (pid:4406) [services] - registered service "tsserver" 2020-12-06T15:22:06.390 INFO (pid:4406) [plugin] - coc.nvim 0.0.79-5a9a0f22a2 initialized with node: v12.18.3 after 310ms 2020-12-06T15:22:06.397 INFO (pid:4406) [services] - eslint langserver state change: starting => running 2020-12-06T15:22:06.402 INFO (pid:4406) [services] - service eslint started 2020-12-06T15:22:06.470 INFO (pid:4406) [services] - service tsserver started 2020-12-06T15:22:11.335 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:11.847 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:11.943 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:12.039 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:12.399 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:16.439 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:16.511 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:16.647 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:16.743 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:16.912 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:17.839 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:17.967 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:18.031 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:18.127 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:18.359 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:19.319 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:19.431 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:19.526 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:19.599 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:19.695 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:20.143 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:20.303 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:20.733 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:20.879 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:21.095 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:21.255 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:21.439 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:22.223 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:23.038 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:23.679 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:24.280 WARN (pid:4406) [completion] - Document not attached, suggest disabled. 2020-12-06T15:22:28.001 INFO (pid:4406) [willSaveHandler] - Will save cost: 297 2020-12-06T15:22:32.343 INFO (pid:4406) [completion-complete] - Results from: around,tsserver-javascript 2020-12-06T15:22:32.959 INFO (pid:4406) [completion-complete] - Results from: tsserver-javascript 2020-12-06T15:22:36.692 INFO (pid:4406) [willSaveHandler] - Will save cost: 157 ```
tsserver.openTsServerLog ``` Info 0 [15:22:06.705] Starting TS Server Info 1 [15:22:06.705] Version: 4.1.2 Info 2 [15:22:06.705] Arguments: /usr/local/bin/node /Users/gaylonalfano/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js --allowLocalPluginLoads --useInferredProjectPerProjectRoot --cancellationPipeName /var/folders/vh/1v1dk5tx0mxb24pnv8dg8myh0000gp/T/nvimDH59Ry/coc.nvim-4406/coc-nvim-tscancellation-7b06c076456e7b28fba3.sock* --logVerbosity verbose --logFile /var/folders/vh/1v1dk5tx0mxb24pnv8dg8myh0000gp/T/nvimDH59Ry/coc.nvim-4406/tsserver.log --npmLocation "/usr/local/bin/npm" --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation Info 3 [15:22:06.705] Platform: darwin NodeVersion: 12 CaseSensitive: false Info 4 [15:22:06.705] ServerMode: undefined syntaxOnly: false hasUnknownServerMode: undefined Info 5 [15:22:06.708] Binding... Info 6 [15:22:06.713] event: {"seq":0,"type":"event","event":"typingsInstallerPid","body":{"pid":4435}} Info 7 [15:22:06.715] request: {"seq":0,"type":"request","command":"configure","arguments":{"hostInfo":"coc-nvim","preferences":{"providePrefixAndSuffixTextForRename":true,"allowRenameOfImportPath":true}}} Info 8 [15:22:06.716] Host information coc-nvim Info 9 [15:22:06.716] response: {"seq":0,"type":"response","command":"configure","request_seq":0,"success":true} Perf 10 [15:22:06.716] 0::configure: async elapsed time (in milliseconds) 0.6263 Info 11 [15:22:06.717] request: {"seq":1,"type":"request","command":"compilerOptionsForInferredProjects","arguments":{"options":{"module":"commonjs","target":"es2016","jsx":"preserve","allowJs":true,"allowSyntheticDefaultImports":true,"allowNonTsExtensions":true}}} Info 12 [15:22:06.717] Scheduled: *ensureProjectForOpenFiles* Perf 13 [15:22:06.717] 1::compilerOptionsForInferredProjects: elapsed time (in milliseconds) 0.5644 Info 14 [15:22:06.718] response: {"seq":0,"type":"response","command":"compilerOptionsForInferredProjects","request_seq":1,"success":true,"body":true} Info 15 [15:22:06.718] request: {"seq":2,"type":"request","command":"open","arguments":{"file":"/Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/main.ts","fileContent":"\n","scriptKindName":"TS","projectRootPath":"/Users/gaylonalfano/Code/typescript-30"}} Info 16 [15:22:06.719] Search path: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow Info 17 [15:22:06.719] ConfigFilePresence:: Current Watches: :: File: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/tsconfig.json Currently impacted open files: RootsOfInferredProjects: OtherOpenFiles: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/main.ts Status: File added to open files impacted by this config file Info 18 [15:22:06.720] ConfigFilePresence:: Current Watches: :: File: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/jsconfig.json Currently impacted open files: RootsOfInferredProjects: OtherOpenFiles: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/main.ts Status: File added to open files impacted by this config file Info 19 [15:22:06.720] ConfigFilePresence:: Current Watches: :: File: /Users/gaylonalfano/Code/typescript-30/tsconfig.json Currently impacted open files: RootsOfInferredProjects: OtherOpenFiles: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/main.ts Status: File added to open files impacted by this config file Info 20 [15:22:06.720] ConfigFilePresence:: Current Watches: :: File: /Users/gaylonalfano/Code/typescript-30/jsconfig.json Currently impacted open files: RootsOfInferredProjects: OtherOpenFiles: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/main.ts Status: File added to open files impacted by this config file Info 21 [15:22:06.720] For info: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/main.ts :: No config files found. Info 22 [15:22:06.722] ConfigFilePresence:: Current Watches: :: File: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/tsconfig.json Currently impacted open files: RootsOfInferredProjects: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/main.ts OtherOpenFiles: Status: Open file was set as Inferred root Info 23 [15:22:06.722] FileWatcher:: Added:: WatchInfo: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/tsconfig.json 2000 undefined Project: WatchType: Config file for the inferred project root Info 24 [15:22:06.722] ConfigFilePresence:: Current Watches: Config file for the inferred project root:: File: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/tsconfig.json Currently impacted open files: RootsOfInferredProjects: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/main.ts OtherOpenFiles: Status: Updated the callback Info 25 [15:22:06.722] ConfigFilePresence:: Current Watches: :: File: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/jsconfig.json Currently impacted open files: RootsOfInferredProjects: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/main.ts OtherOpenFiles: Status: Open file was set as Inferred root Info 26 [15:22:06.723] FileWatcher:: Added:: WatchInfo: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/jsconfig.json 2000 undefined Project: WatchType: Config file for the inferred project root Info 27 [15:22:06.723] ConfigFilePresence:: Current Watches: Config file for the inferred project root:: File: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/jsconfig.json Currently impacted open files: RootsOfInferredProjects: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/main.ts OtherOpenFiles: Status: Updated the callback Info 28 [15:22:06.723] ConfigFilePresence:: Current Watches: :: File: /Users/gaylonalfano/Code/typescript-30/tsconfig.json Currently impacted open files: RootsOfInferredProjects: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/main.ts OtherOpenFiles: Status: Open file was set as Inferred root Info 29 [15:22:06.723] FileWatcher:: Added:: WatchInfo: /Users/gaylonalfano/Code/typescript-30/tsconfig.json 2000 undefined Project: WatchType: Config file for the inferred project root Info 30 [15:22:06.723] ConfigFilePresence:: Current Watches: Config file for the inferred project root:: File: /Users/gaylonalfano/Code/typescript-30/tsconfig.json Currently impacted open files: RootsOfInferredProjects: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/main.ts OtherOpenFiles: Status: Updated the callback Info 31 [15:22:06.723] ConfigFilePresence:: Current Watches: :: File: /Users/gaylonalfano/Code/typescript-30/jsconfig.json Currently impacted open files: RootsOfInferredProjects: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/main.ts OtherOpenFiles: Status: Open file was set as Inferred root Info 32 [15:22:06.723] FileWatcher:: Added:: WatchInfo: /Users/gaylonalfano/Code/typescript-30/jsconfig.json 2000 undefined Project: WatchType: Config file for the inferred project root Info 33 [15:22:06.723] ConfigFilePresence:: Current Watches: Config file for the inferred project root:: File: /Users/gaylonalfano/Code/typescript-30/jsconfig.json Currently impacted open files: RootsOfInferredProjects: /Users/gaylonalfano/Code/typescript-30/16 - Mouse Move Shadow/main.ts OtherOpenFiles: Status: Updated the callback Info 34 [15:22:06.724] Starting updateGraphWorker: Project: /dev/null/inferredProject1* Info 35 [15:22:06.731] DirectoryWatcher:: Added:: WatchInfo: /users/gaylonalfano/.config/coc/extensions/node_modules 1 undefined Project: WatchType: node_modules for closed script infos in them Info 36 [15:22:06.737] Elapsed:: 5.6605360000394285ms DirectoryWatcher:: Added:: WatchInfo: /users/gaylonalfano/.config/coc/extensions/node_modules 1 undefined Project: WatchType: node_modules for closed script infos in them Info 37 [15:22:07.780] DirectoryWatcher:: Added:: WatchInfo: /Users/gaylonalfano/Code/typescript-30/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots Info 38 [15:22:07.781] Elapsed:: 0.6604000004008412ms DirectoryWatcher:: Added:: WatchInfo: /Users/gaylonalfano/Code/typescript-30/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots Info 39 [15:22:07.781] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* Version: 1 structureChanged: true Elapsed: 1057.271775000263ms Info 40 [15:22:07.781] Project '/dev/null/inferredProject1*' (Inferred) Info 41 [15:22:07.781] Files (19) /Users/gaylonalfano/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/lib.es5.d.ts /Users/gaylonalfano/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/lib.es2015.d.ts /Users/gaylonalfano/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/lib.es2016.d.ts /Users/gaylonalfano/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/lib.dom.d.ts /Users/gaylonalfano/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/lib.dom.iterable.d.ts /Users/gaylonalfano/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/lib.webworker.importscripts.d.ts ```

After confirming that my TS version is consistent with coc-tsserver, I still encounter the same behavior. I've tried :CocRestart and all sorts of things. Any assistance is greatly appreciated! 百思不得其解!麻烦你了!

chemzqm commented 3 years ago

Document not attached, could be wrong buftype try minimal vimrc

gaylonalfano commented 3 years ago

Just circling back to update. After simplifying my CoC configuration in init.vim, I came across a setting I used during a previous Deno project, when I was dealing with a lot of data from another buffer and was having issues with Coc/TS:

autocmd FileType typescript :let b:coc_enabled = 0

After removing this line, everything started working again just fine. Thanks again for your assistance!