vknabel / vscode-swift-development-environment

New home of Swift Development Environment for VS Code
https://marketplace.visualstudio.com/items?itemName=vknabel.vscode-swift-development-environment
Apache License 2.0
175 stars 14 forks source link

Add command to restart the LSP #82

Closed clayreimann closed 3 years ago

clayreimann commented 3 years ago

I've noticed that sometimes when I add code I get the language server stuck and wind up with errors about not finding modules or functions. In such cases if I restart the extension host (which restarts the LSP) things go back to normal. However that restarts all extensions running in VSCode and is rather heavy weight.

image

The VSCode golang extension has a handy option to restart the language server, and I think it'd be cool if this extension had a similar option.

vknabel commented 3 years ago

Hi @clayreimann, great suggestion!

This will probably require some refactorings, but opens up lots of great improvements.

clayreimann commented 3 years ago

@vknabel any pointers on where I can look to start this?

vknabel commented 3 years ago

Hi @clayreimann, sorry for the late response. I'd be happy to see a PR! Thanks for considering.

Not sure if you have already seen it: the CONTRIBUTING.md gives a little bit of context. Though not a lot. 😅

Not sure regarding your background in VS Code extensions. This project uses yarn instead of npm, it also uses prettier to format code. The debugger settings should already be set up in VS Code.

Essentially this feature is about adding a new command to the package.json. The rest is currently implemented in src/clientMain.ts:

In activate the command to restart must be registered (commands.registerCommand). In there all subscriptions added to the ExtensionContext must be disposed.

Thereafter you should be able to call activate again. If I didn't forget anything, that's it.

Don't hesitate to ask any questions. The clientMain.ts file isn't in best shape and is quite hacky. I'll try to answer much faster next time 😊

Edit: you can also write down any points to improve, what questions you had and problems you had. Would be really helpful to improve docs!

vknabel commented 3 years ago

Thanks a lot @clayreimann for your great work and effort you put into your PR!