fix(daemon): launch LSP servers with caller env

This commit is contained in:
2026-05-02 15:28:25 -04:00
parent 306771f92a
commit 04fd520438
5 changed files with 80 additions and 20 deletions

View File

@@ -5,7 +5,11 @@
// Why Not One Persistent Socket - For now we open a fresh connection per
// request. The cost is negligible (Unix socket, same machine) compared to
// the LSP request itself, and it keeps client code stateless.
import { sendOnce, type DaemonResponse } from "./daemonProtocol.ts";
import {
buildLaunchContext,
sendOnce,
type DaemonResponse,
} from "./daemonProtocol.ts";
// Unwrap - Throws on { ok: false }, returns result on { ok: true }. All
// callers want the result-or-throw shape, so we centralize it.
@@ -21,7 +25,15 @@ export async function daemonRequest(
method: string,
params: Record<string, unknown>,
): Promise<unknown> {
return unwrap(await sendOnce({ op: "request", file, method, params }));
return unwrap(
await sendOnce({
op: "request",
file,
method,
params,
launch: buildLaunchContext(),
}),
);
}
// Wait For Diagnostics - Diagnostics arrive as a notification, not a
@@ -30,7 +42,14 @@ export async function daemonDiagnostics(
file: string,
timeoutMs = 1500,
): Promise<unknown> {
return unwrap(await sendOnce({ op: "diagnostics", file, timeoutMs }));
return unwrap(
await sendOnce({
op: "diagnostics",
file,
timeoutMs,
launch: buildLaunchContext(),
}),
);
}
// Status - Lists currently-cached LSP servers (id, root, opened files,