Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion LSP.sc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ LSPConnection {
Log('LanguageServer.quark').info("Found method provider: %", provider);

// Preprocess param values into a usable state
preprocessor.value(params);
params !? {
preprocessor.value(params);
};

Deferred().using({
provider.handleRequest(method, params);
Expand Down
41 changes: 41 additions & 0 deletions Providers/ShutdownProvider.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#shutdown
ShutdownProvider : LSPProvider {
var receivedShutdown = false;

*methodNames {
^[
"shutdown",
"exit"
]
}

*clientCapabilityName { ^nil }
*serverCapabilityName { ^nil }

init {
|clientCapabilities|
// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#declarationClientCapabilities
}

options {
// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentSyncOptions
^()
}

handleRequest {
|method, params|
var code;
Log('LanguageServer.quark').info("Handling: %", method);
switch (method)
{ 'shutdown' } {
Log('LanguageServer.quark').info("Preparing to shutdown");
receivedShutdown = true;
^(result: "null", code: 0);
}
{ 'exit' } {
code = receivedShutdown.if(0, 1);
code.exit;
^nil;
}
}
}