feat: add lua, html/css/json, nix, and oxlint LSPs; add global .git root marker
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user