import { execFileSync } from "node:child_process";
export const LSP_SERVERS = {
    typescript: {
        command: "typescript-language-server",
        args: ["--stdio"],
        languages: ["typescript", "javascript", "tsx", "jsx"],
    },
    python: {
        command: "pylsp",
        args: [],
        languages: ["python"],
    },
    go: {
        command: "gopls",
        args: ["serve"],
        languages: ["go"],
    },
    rust: {
        command: "rust-analyzer",
        args: [],
        languages: ["rust"],
    },
    ruby: {
        command: "solargraph",
        args: ["stdio"],
        languages: ["ruby"],
    },
    php: {
        command: "intelephense",
        args: ["--stdio"],
        languages: ["php"],
    },
    kotlin: {
        command: "kotlin-language-server",
        args: [],
        languages: ["kotlin"],
    },
};
export function getLspConfigForLanguage(language) {
    for (const [name, config] of Object.entries(LSP_SERVERS)) {
        if (config.languages.includes(language)) {
            return { name, config };
        }
    }
    return null;
}
const availabilityCache = new Map();
export function isLspAvailable(config) {
    const cached = availabilityCache.get(config.command);
    if (cached !== undefined)
        return cached;
    try {
        execFileSync("which", [config.command], { stdio: "ignore" });
        availabilityCache.set(config.command, true);
        return true;
    }
    catch {
        availabilityCache.set(config.command, false);
        return false;
    }
}
//# sourceMappingURL=lsp-servers.js.map