mirror of
https://github.com/cfngc4594/monaco-editor-lsp-next.git
synced 2025-05-18 15:26:36 +00:00
feat(shiki): improve Shiki highlighter initialization with dynamic theme and language support
This commit is contained in:
parent
6d9c6701d4
commit
1f417fb4e6
@ -1,12 +1,23 @@
|
||||
import { MonacoTheme } from "@/types/monaco-theme";
|
||||
import { createHighlighter, Highlighter } from "shiki";
|
||||
import { EditorLanguage } from "@/types/editor-language";
|
||||
|
||||
// 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() {
|
||||
highlighter = await createHighlighter({
|
||||
themes: ["github-light-default", "github-dark-default"],
|
||||
langs: ["c"],
|
||||
});
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user