feat(servers): split vscode-html-language-server and add css, json, bash, sql servers

- Split vscode-html-language-server into separate servers for HTML, CSS,
  and JSON with proper language IDs and file extensions
- Added bash-language-server for shell scripts (.sh, .bash)
- Added sqls for SQL files
- Added timeout wrapper to auto-check diagnostics to prevent blocking pi
This commit is contained in:
2026-05-08 18:51:12 -04:00
parent 46e3cc4ccd
commit e143e05758
2 changed files with 48 additions and 3 deletions

View File

@@ -334,6 +334,18 @@ function pickDiagnosticServers(filePath: string): string[] {
.map((s) => s.id); .map((s) => s.id);
} }
// Timeout Wrapper - Rejects a promise after the given number of milliseconds.
// Used to prevent async hooks from blocking pi indefinitely.
function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T> {
return new Promise((resolve, reject) => {
const timer = setTimeout(() => reject(new Error(`Timeout after ${ms}ms`)), ms);
promise.then(
(value) => { clearTimeout(timer); resolve(value); },
(reason) => { clearTimeout(timer); reject(reason); },
);
});
}
// Run LSP Diagnostics - Fans out to all matching servers in a single // Run LSP Diagnostics - Fans out to all matching servers in a single
// daemon call. Returns the grouped result map or undefined if no servers. // daemon call. Returns the grouped result map or undefined if no servers.
async function runDiagnostics(filePath: string): Promise<unknown> { async function runDiagnostics(filePath: string): Promise<unknown> {
@@ -557,8 +569,9 @@ export default function (pi: ExtensionAPI) {
const absolutePath = path.resolve(ctx.cwd, filePath); const absolutePath = path.resolve(ctx.cwd, filePath);
try { try {
// Run LSP diagnostics // Run LSP diagnostics with timeout - Prevent the auto-check hook from
const result = await runDiagnostics(absolutePath); // blocking pi if the daemon or LSP server is slow or unresponsive.
const result = await withTimeout(runDiagnostics(absolutePath), 3000);
const formatted = formatDiagnostics(result, 10); const formatted = formatDiagnostics(result, 10);
// Only send a message if there are actual diagnostics // Only send a message if there are actual diagnostics

View File

@@ -100,12 +100,44 @@ export const servers: ServerConfig[] = [
}, },
{ {
id: "vscode-html-language-server", id: "vscode-html-language-server",
match: ["html", "css", "jsonl", "jsonc", "json"], match: ["html"],
command: "vscode-html-language-server", command: "vscode-html-language-server",
args: ["--stdio"], args: ["--stdio"],
rootMarkers: ["package.json"], rootMarkers: ["package.json"],
languageId: "html", languageId: "html",
}, },
{
id: "vscode-css-language-server",
match: ["css", "scss", "less"],
command: "vscode-css-language-server",
args: ["--stdio"],
rootMarkers: ["package.json"],
languageId: "css",
},
{
id: "vscode-json-language-server",
match: ["json", "jsonc", "jsonl"],
command: "vscode-json-language-server",
args: ["--stdio"],
rootMarkers: ["package.json"],
languageId: "json",
},
{
id: "bash-language-server",
match: ["sh", "bash"],
command: "bash-language-server",
args: ["start"],
rootMarkers: [".git"],
languageId: "shellscript",
},
{
id: "sqls",
match: ["sql"],
command: "sqls",
args: [],
rootMarkers: [".git"],
languageId: "sql",
},
{ {
id: "nil", id: "nil",
match: ["nix"], match: ["nix"],