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:
17
index.ts
17
index.ts
@@ -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
|
||||||
|
|||||||
34
server.ts
34
server.ts
@@ -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"],
|
||||||
|
|||||||
Reference in New Issue
Block a user