diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-21 13:00:28 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-21 13:00:28 +0000 |
| commit | 23cc0711cc35db9b3251bd02d5abf64eb3634fd6 (patch) | |
| tree | d89eb2ca032a863c7304c2e57fd1e1b6018dbd87 /bundle/src/editor.js | |
| parent | df84eb98170800edcc16ff1af0a1c81dc7c103ef (diff) | |
fix(bundle): switch editor to 2026 Dark and set default text foreground
Plain identifiers rendered black because the TextMate theme had no
scope-less default entry. Vendor the 2026 Dark include chain and
prepend the editor foreground/background as the default.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'bundle/src/editor.js')
| -rw-r--r-- | bundle/src/editor.js | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/bundle/src/editor.js b/bundle/src/editor.js index eaef000..e351c9d 100644 --- a/bundle/src/editor.js +++ b/bundle/src/editor.js @@ -16,14 +16,21 @@ import grammar from '../../plugin/syntaxes/cie-pseudocode.tmLanguage.json'; import configuration from '../../plugin/language-configuration.json'; import indentation from '../../plugin/src/indentation.js'; import brackets from '../../plugin/src/brackets.js'; -import darkPlusSource from '../vendor/vscode/dark_plus.json?raw'; -import darkSource from '../vendor/vscode/dark_vs.json?raw'; +const sources = import.meta.glob('../vendor/vscode/*.json', { query: '?raw', import: 'default', eager: true }); const languageId = 'cie-pseudocode'; const { indentationEdits, onTypeCharacters, shouldFormatOnType, selectionEndLine } = indentation; -const dark = parse(darkSource); -const plus = parse(darkPlusSource); -export const theme = { ...dark, ...plus, tokenColors: [...dark.tokenColors, ...plus.tokenColors] }; +function loadTheme(name) { + const child = parse(sources[`../vendor/vscode/${name}.json`]); + if (!child.include) return child; + const parent = loadTheme(child.include.replace(/^\.\//, '').replace(/\.json$/, '')); + return { ...parent, ...child, colors: { ...parent.colors, ...child.colors }, tokenColors: [...(parent.tokenColors ?? []), ...(child.tokenColors ?? [])] }; +} +const dark = loadTheme('2026-dark'); +export const theme = { + ...dark, + tokenColors: [{ settings: { foreground: dark.colors['editor.foreground'], background: dark.colors['editor.background'] } }, ...dark.tokenColors] +}; class TokenState { constructor(stack) { this.stack = stack; } @@ -44,8 +51,8 @@ export async function createEditor(element) { monaco.languages.register({ id: languageId, extensions: ['.cps'] }); monaco.languages.setLanguageConfiguration(languageId, { ...configuration, wordPattern: new RegExp(configuration.wordPattern) }); const tmGrammar = await registry.loadGrammarWithConfiguration(grammar.scopeName, monaco.languages.getEncodedLanguageId(languageId), { balancedBracketSelectors: ['*'] }); - monaco.editor.defineTheme('cpsc-dark-plus', { base: 'vs-dark', inherit: false, rules: [], colors: dark.colors }); - monaco.editor.setTheme('cpsc-dark-plus'); + monaco.editor.defineTheme('cpsc-dark-2026', { base: 'vs-dark', inherit: false, rules: [], colors: dark.colors }); + monaco.editor.setTheme('cpsc-dark-2026'); monaco.languages.setColorMap(registry.getColorMap()); monaco.languages.setTokensProvider(languageId, { getInitialState: () => new TokenState(INITIAL), @@ -72,7 +79,7 @@ export async function createEditor(element) { } }); const editor = monaco.editor.create(element, { - language: languageId, theme: 'cpsc-dark-plus', automaticLayout: true, + language: languageId, theme: 'cpsc-dark-2026', automaticLayout: true, insertSpaces: false, tabSize: 4, detectIndentation: false, autoIndent: 'full', formatOnType: true, bracketPairColorization: { enabled: true, independentColorPoolPerBracketType: false }, minimap: { enabled: false }, smoothScrolling: false, cursorSmoothCaretAnimation: 'off', |
