diff --git a/src/config/language-server.ts b/src/config/language-server.ts new file mode 100644 index 0000000..86bf076 --- /dev/null +++ b/src/config/language-server.ts @@ -0,0 +1,22 @@ +import { EditorLanguage } from "@/types/editor-language"; +import { EditorLanguageConfig } from "./editor-language"; +import { LanguageServerMetadata } from "@/types/language-server"; + +const LanguageServerConfig: Record = { + [EditorLanguage.C]: { + protocol: "ws", + hostname: "localhost", + port: 4594, + path: "/clangd", + lang: EditorLanguageConfig[EditorLanguage.C], + }, + [EditorLanguage.CPP]: { + protocol: "ws", + hostname: "localhost", + port: 4595, + path: "/clangd", + lang: EditorLanguageConfig[EditorLanguage.CPP], + }, +}; + +export default LanguageServerConfig; diff --git a/src/hooks/use-monaco-theme.ts b/src/hooks/use-monaco-theme.ts index 5797e88..847f85a 100644 --- a/src/hooks/use-monaco-theme.ts +++ b/src/hooks/use-monaco-theme.ts @@ -1,10 +1,11 @@ import { useTheme } from "next-themes"; +import { MonacoTheme } from "@/types/monaco-theme"; import { MonacoThemeConfig } from "@/config/monaco-theme"; export function useMonacoTheme() { const { resolvedTheme } = useTheme(); - const monacoTheme = resolvedTheme === "light" ? MonacoThemeConfig.light : MonacoThemeConfig.dark; + const monacoTheme = resolvedTheme === "light" ? MonacoThemeConfig[MonacoTheme.GitHubLightDefault] : MonacoThemeConfig[MonacoTheme.GitHubDarkDefault]; return { monacoTheme, diff --git a/src/lib/utils.ts b/src/lib/utils.ts index bd0c391..d31d869 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,6 +1,13 @@ -import { clsx, type ClassValue } from "clsx" -import { twMerge } from "tailwind-merge" +import { twMerge } from "tailwind-merge"; +import { clsx, type ClassValue } from "clsx"; +import { EditorLanguage } from "@/types/editor-language"; +import languageServerConfigs from "@/config/language-server"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } + +export function getPath(lang: EditorLanguage): string { + const config = languageServerConfigs[lang]; + return `file:///${config.lang.fileName}${config.lang.fileExtension}`; +} diff --git a/src/types/language-server.ts b/src/types/language-server.ts new file mode 100644 index 0000000..700e2f8 --- /dev/null +++ b/src/types/language-server.ts @@ -0,0 +1,9 @@ +import { EditorLanguageMetadata } from "./editor-language"; + +export type LanguageServerMetadata = { + protocol: string; + hostname: string; + port: number | null; + path: string | null; + lang: EditorLanguageMetadata; +};