feat(language-server): add environment variable support for configuration

This commit is contained in:
cfngc4594 2025-03-05 08:33:38 +08:00
parent 470fa306c2
commit 2a47b469b0

View File

@ -4,17 +4,17 @@ import { LanguageServerMetadata } from "@/types/language-server";
const LanguageServerConfig: Record<EditorLanguage, LanguageServerMetadata> = { const LanguageServerConfig: Record<EditorLanguage, LanguageServerMetadata> = {
[EditorLanguage.C]: { [EditorLanguage.C]: {
protocol: "ws", protocol: process.env.NEXT_PUBLIC_LSP_C_PROTOCOL || "ws",
hostname: "localhost", hostname: process.env.NEXT_PUBLIC_LSP_C_HOSTNAME || "localhost",
port: 4594, port: process.env.NEXT_PUBLIC_LSP_C_PORT ? parseInt(process.env.NEXT_PUBLIC_LSP_C_PORT, 10) : 4594,
path: "/clangd", path: process.env.NEXT_PUBLIC_LSP_C_PATH || "/clangd",
lang: EditorLanguageConfig[EditorLanguage.C], lang: EditorLanguageConfig[EditorLanguage.C],
}, },
[EditorLanguage.CPP]: { [EditorLanguage.CPP]: {
protocol: "ws", protocol: process.env.NEXT_PUBLIC_LSP_CPP_PROTOCOL || "ws",
hostname: "localhost", hostname: process.env.NEXT_PUBLIC_LSP_CPP_HOSTNAME || "localhost",
port: 4595, port: process.env.NEXT_PUBLIC_LSP_CPP_PORT ? parseInt(process.env.NEXT_PUBLIC_LSP_CPP_PORT, 10) : 4595,
path: "/clangd", path: process.env.NEXT_PUBLIC_LSP_CPP_PATH || "/clangd",
lang: EditorLanguageConfig[EditorLanguage.CPP], lang: EditorLanguageConfig[EditorLanguage.CPP],
}, },
}; };