From 630226a00a4ef340a20f033cec40f4f204125469 Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Mon, 4 May 2026 06:59:08 -0400 Subject: [PATCH] feat: add lua, html/css/json, nix, and oxlint LSPs; add global .git root marker --- server.ts | 35 +++++++++++++++++++++++++++++++++++ src/root.ts | 5 +++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/server.ts b/server.ts index 2ce376d..9c94c44 100644 --- a/server.ts +++ b/server.ts @@ -5,6 +5,9 @@ // language ids; either matches. import type { ServerConfig } from "./src/types.ts"; +// Global Root Markers — appended to every server's rootMarkers list +export const globalRootMarkers = [".git"]; + export const servers: ServerConfig[] = [ { id: "gopls", @@ -30,4 +33,36 @@ export const servers: ServerConfig[] = [ rootMarkers: ["pyproject.toml", "setup.py", "setup.cfg"], languageId: "python", }, + { + id: "lua-language-server", + match: ["lua"], + command: "lua-language-server", + args: [], + rootMarkers: [".luarc.json"], + languageId: "lua", + }, + { + id: "vscode-html-language-server", + match: ["html", "css", "jsonl", "jsonc", "json"], + command: "vscode-html-language-server", + args: ["--stdio"], + rootMarkers: ["package.json"], + languageId: "html", + }, + { + id: "nil", + match: ["nix"], + command: "nil", + args: [], + rootMarkers: ["flake.nix"], + languageId: "nix", + }, + { + id: "oxlint", + match: ["ts", "tsx", "js", "jsx", "mjs", "cjs"], + command: "oxlint", + args: ["--lsp"], + rootMarkers: [".oxlintrc.json", "oxlint.config.json"], + languageId: "typescript", + }, ]; diff --git a/src/root.ts b/src/root.ts index 158f9da..3cdb3d3 100644 --- a/src/root.ts +++ b/src/root.ts @@ -1,7 +1,7 @@ import * as fs from "node:fs"; import * as path from "node:path"; import { pathToFileURL, fileURLToPath } from "node:url"; -import { servers } from "../server.ts"; +import { servers, globalRootMarkers } from "../server.ts"; import type { ServerConfig } from "./types.ts"; import { UnsupportedExtensionError } from "./types.ts"; @@ -31,8 +31,9 @@ export function pickServer(filePath: string): ServerConfig { export function findRoot(filePath: string, markers: string[]): string { let dir = path.dirname(path.resolve(filePath)); const { root } = path.parse(dir); + const allMarkers = [...markers, ...globalRootMarkers]; while (true) { - for (const m of markers) { + for (const m of allMarkers) { if (fs.existsSync(path.join(dir, m))) return dir; } if (dir === root) return path.dirname(path.resolve(filePath));