mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-22 02:04:22 +01:00
sync
This commit is contained in:
31
js/src/lsp/index.ts
Normal file
31
js/src/lsp/index.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user