feat: add lua, html/css/json, nix, and oxlint LSPs; add global .git root marker

This commit is contained in:
2026-05-04 06:59:08 -04:00
parent f811efef68
commit 630226a00a
2 changed files with 38 additions and 2 deletions

View File

@@ -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",
},
];

View File

@@ -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));