This commit is contained in:
Dax Raad
2025-05-20 22:00:00 -04:00
parent 9b564f0b73
commit 2860a2bb1a
11 changed files with 505 additions and 173 deletions

31
js/src/lsp/index.ts Normal file
View File

@@ -0,0 +1,31 @@
import { App } from "../app";
import { Log } from "../util/log";
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>();
clients.set(
"typescript",
await LSPClient.create({
cmd: ["bun", "x", "typescript-language-server", "--stdio"],
}),
);
return {
clients,
diagnostics: new Map<string, any>(),
};
});
export async function run<T>(
input: (client: LSPClient.Info) => Promise<T>,
): Promise<T[]> {
const clients = await state().then((x) => [...x.clients.values()]);
const tasks = clients.map((x) => input(x));
return Promise.all(tasks);
}
}