mirror of
https://github.com/cfngc4594/monaco-editor-lsp-next.git
synced 2025-05-18 15:26:36 +00:00
26 lines
767 B
TypeScript
26 lines
767 B
TypeScript
import { MonacoTheme } from "@/types/monaco-theme";
|
|
import { EditorLanguage } from "@/generated/client";
|
|
import { createHighlighter, Highlighter } from "shiki";
|
|
|
|
// Get all values from the ProgrammingLanguage and Theme enums
|
|
const themes = Object.values(MonacoTheme);
|
|
const languages = Object.values(EditorLanguage);
|
|
|
|
// Use lazy initialization for highlighter
|
|
let highlighter: Highlighter;
|
|
|
|
async function initializeHighlighter() {
|
|
try {
|
|
highlighter = await createHighlighter({
|
|
themes: themes, // Use all values from the Theme enum
|
|
langs: languages, // Use all values from the ProgrammingLanguage enum
|
|
});
|
|
} catch (error) {
|
|
console.error("Error initializing highlighter:", error);
|
|
}
|
|
}
|
|
|
|
initializeHighlighter();
|
|
|
|
export { highlighter };
|