diff --git a/LSP.sc b/LSP.sc index 0185448..8216e58 100644 --- a/LSP.sc +++ b/LSP.sc @@ -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); diff --git a/Providers/ShutdownProvider.sc b/Providers/ShutdownProvider.sc new file mode 100644 index 0000000..5bc0c4c --- /dev/null +++ b/Providers/ShutdownProvider.sc @@ -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; + } + } +}