diff options
| author | Dax Raad <[email protected]> | 2025-05-26 14:52:38 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-05-26 14:52:38 -0400 |
| commit | b87ba57819a3dfa458b34c9cec9362c7028adf6e (patch) | |
| tree | e12932e8dd7ac54c92ca337b9c975d7b4b143561 /js/src/lsp | |
| parent | 802389a90eaa9a173a98305003b9e58b95584cd1 (diff) | |
| download | opencode-b87ba57819a3dfa458b34c9cec9362c7028adf6e.tar.gz opencode-b87ba57819a3dfa458b34c9cec9362c7028adf6e.zip | |
shutdown
Diffstat (limited to 'js/src/lsp')
| -rw-r--r-- | js/src/lsp/client.ts | 5 | ||||
| -rw-r--r-- | js/src/lsp/index.ts | 36 | ||||
| -rw-r--r-- | js/src/lsp/language.ts | 2 |
3 files changed, 28 insertions, 15 deletions
diff --git a/js/src/lsp/client.ts b/js/src/lsp/client.ts index f07b21c7f..0c9f9d06c 100644 --- a/js/src/lsp/client.ts +++ b/js/src/lsp/client.ts @@ -178,6 +178,11 @@ export namespace LSPClient { }), ]); }, + async shutdown() { + log.info("shutting down"); + connection.end(); + connection.dispose(); + }, }; return result; diff --git a/js/src/lsp/index.ts b/js/src/lsp/index.ts index f20a15e70..80503fb1f 100644 --- a/js/src/lsp/index.ts +++ b/js/src/lsp/index.ts @@ -5,22 +5,30 @@ import { LSPClient } from "./client"; export namespace LSP { const log = Log.create({ service: "lsp" }); - const state = App.state("lsp", async () => { - const clients = new Map<string, LSPClient.Info>(); + const state = App.state( + "lsp", + async () => { + const clients = new Map<string, LSPClient.Info>(); - // QUESTION: how lazy should lsp auto discovery be? should it not initialize until a file is opened? - clients.set( - "typescript", - await LSPClient.create({ - cmd: ["bun", "x", "typescript-language-server", "--stdio"], - }), - ); + // QUESTION: how lazy should lsp auto discovery be? should it not initialize until a file is opened? + clients.set( + "typescript", + await LSPClient.create({ + cmd: ["bun", "x", "typescript-language-server", "--stdio"], + }), + ); - return { - clients, - diagnostics: new Map<string, any>(), - }; - }); + return { + clients, + diagnostics: new Map<string, any>(), + }; + }, + async (state) => { + for (const client of state.clients.values()) { + await client.shutdown(); + } + }, + ); export async function run<T>( input: (client: LSPClient.Info) => Promise<T>, diff --git a/js/src/lsp/language.ts b/js/src/lsp/language.ts index 964ebc803..14b32edfa 100644 --- a/js/src/lsp/language.ts +++ b/js/src/lsp/language.ts @@ -1,4 +1,4 @@ -export const LANGUAGE_EXTENSIONS = { +export const LANGUAGE_EXTENSIONS: Record<string, string> = { ".abap": "abap", ".bat": "bat", ".bib": "bibtex", |
