Wanted: easy way to restart LSPs

(This may reflect the fact that I’m not a Javascript guru.)

When wiring up an LSP, it would be nice to have a clean way to restart language servers. You can’t just start up another instance, because that leads to errors.

You also can’t use a promise, at least not without some extra games, because stop() doesn’t return a promise you can wait for. :frowning:

So if you want to restart the server, you wind up with some pretty ugly code in the onDidStop() thing, that you set up just to restart.

What would be nice is a simpler solution. Either a synchronous solution (maybe a version of restart() that takes the old client object, and the arguments that you pass to start today), or an easier way to wait on the current stop() function (maybe it could return a waitable Promise?)

I’ve struggled mightily getting server restarts to work well, because e.g. a user can configure a different language server, or different arguments, etc. The experience is less than ideal, IMO.


Sadly, it seems most language servers will at some point get lost with respect to the state of the workspace so providing a restart command for your extension is necessary evil. It would also be nice if it were easier to wait on start() for when Nova and the server have initialized, other than polling on the running property of the client.

Thank you for your thoughts on this. I’ll make notes for us to consider new API exposed for either restarting a language sever explicitly or more useful callbacks in these cases (including a callback invoked after initialization is complete).

For the record, what I’ve found works fairly reliably for me, is to issue stop, and then stop, but use a unique “identifier” for the new client. (I append Date.now().). This is kind of a dirty hack, and I don’t like it, but it got me over the hump.