sublimelsp / LSP-typescript

TypeScript, JavaScript support for Sublime LSP plugin
MIT License
132 stars 11 forks source link

Setting up LSP-typescript with LSP-file-watcher-chokidar #188

Closed martinstark closed 1 year ago

martinstark commented 1 year ago

Since I detected that the Sublime LSP is unable to detect changes to files, even if it is the LSP itself that initiated those changes, I found the LSP-file-watcher-chokidar plugin via https://github.com/sublimelsp/LSP/issues/892 to fix the issue.

For example, if I run a script that deletes and re-builds type definitions, the new files will not be picked up by LSP.

I'm wondering if I can set up LSP-Typescript to run with "file-watcher" patterns. It seems I have to write my own clients configuration for LSP-Typescript, and I'm unsure how it should look in order to preserve native LSP-typescript behaviour.

image

rchl commented 1 year ago

If you are using LSP-typescript then you should not be writing your own client configuration. You should put all your options in LSP-typescript settings.

As for file watching, the typescript LSP server doesn't support external file watcher so none of this will make any difference. In that case the server runs its own watcher. You can configure some aspects of it through tsconfig.json but I'm not sure you really should be touching it. I doubt that will fix any issues you have. :)

martinstark commented 1 year ago

Isn't the file watcher in the tsconfig just for running an external hot reload dev server, and not something that affects the LSP?

So just for my understanding, https://github.com/sublimelsp/LSP/issues/892 is not a problem in LSP-typescript, because it already watches for file changes on its own? For example, if I run git checkout . on all local changes in an external terminal, Sublime will pick up that the changes have been reverted, but the LSP will not. My understanding is that the LSP-file-watcher-chokidar plugin polyfills the missing feature in Sublime to make this work.

rchl commented 1 year ago

Isn't the file watcher in the tsconfig just for running an external hot reload dev server, and not something that affects the LSP?

Those options should also affect the LSP case although I admit I've never played with them as I didn't have a need. LSP-typescript is a thin wrapper for https://github.com/typescript-language-server/typescript-language-server LSP server which is a thin wrapper for tsserver which is part of TypeScript. tsserver does all the real work and respects tsconfig.json options. So same options should apply whether using the LSP or compiling using tsc from the command line.

The https://github.com/typescript-language-server/typescript-language-server LSP server doesn't support file watching itself so LSP-file-watcher-chokidar wouldn't make any difference because you can't notify server about file changes if the server doesn't support that functionality. tsserver handles file watching itself.

As far as issues with changing branches. I generally don't have those but I guess it can depend on a project. Whether the project needs to be compiled or not after changing branches for example...

I know there are some improvements in latest version of Typescript (tsserver) to work better in this case but it's all ultimately up to it to handle it.

martinstark commented 1 year ago

Thank you kindly, I'll close this until I better understand the limitations I seem to be running into compared to my workflow in WebStorm. I must be conflating this with other issues I'm running into.