scztt / LanguageServer.quark

17 stars 10 forks source link

Add shutdown provider #4

Open davidgranstrom opened 2 years ago

davidgranstrom commented 2 years ago

Hi!

This is an attempt to implement shutdown requests.

This is useful for the stdio adapter that communicates with the nvim LSP client so that we can shut down the node process on nvim exit and thus freeing the open ports.

I did not implement this part of the spec:

If a server receives requests after a shutdown request those requests should error with InvalidRequest.

We could perhaps set a flag in LSPConnection to signal when a shutdown request has been received, but I did not want to complicate the code until I get to know the code base a bit better.

scztt commented 2 years ago

Apart from my comments, this looks good! Hopefully the LSPProvider API is clear to implement things, I'm open to feedback.

I agree, I think shutdown should probably be owned by LSPConnection, and the provider should just signal to it somehow. In the future maybe we add ShutdownProvider as a "default" provider in addition to InitializeProvider, and then listen for changes via addDependant. But this is fine for now, it's very clean as it is.