feat: warm-start LSP server on file read
This commit is contained in:
19
index.ts
19
index.ts
@@ -432,6 +432,25 @@ export default function (pi: ExtensionAPI) {
|
||||
default: true,
|
||||
});
|
||||
|
||||
// Background Init on Read - Fire-and-forget LSP initialization when the
|
||||
// LLM reads a file with a supported extension. Doesn't block the read,
|
||||
// just ensures the server is warm by the time an LSP tool is called.
|
||||
pi.on("tool_result", async (event, ctx) => {
|
||||
if (event.toolName !== "read" || event.isError) return;
|
||||
|
||||
const filePath = event.input?.path;
|
||||
if (!filePath || typeof filePath !== "string") return;
|
||||
|
||||
try {
|
||||
const absolutePath = path.resolve(ctx.cwd, filePath);
|
||||
// daemonDiagnostics triggers getOrCreateEntry + syncFile in the daemon.
|
||||
// We don't await it — just fire and forget so the server starts warming up.
|
||||
void daemonDiagnostics(absolutePath);
|
||||
} catch {
|
||||
// Silently ignore — unsupported file type, missing binary, etc.
|
||||
}
|
||||
});
|
||||
|
||||
// Auto-Check After Edit/Write - Run diagnostics automatically
|
||||
pi.on("tool_result", async (event, ctx) => {
|
||||
// Check Enabled
|
||||
|
||||
Reference in New Issue
Block a user