This commit is contained in:
Dax Raad
2025-05-26 14:52:38 -04:00
parent 802389a90e
commit b87ba57819
5 changed files with 63 additions and 25 deletions

View File

@@ -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>,