feat: improved config file handling in monaco#1827
Conversation
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR updates Fluidd’s Monaco integration for Klipper/Moonraker configuration files by switching to dedicated Monarch tokenizers (with parser-aligned comment handling), extending Monaco language workers to support Moonraker configs, and removing obsolete TextMate/theme-conversion assets.
Changes:
- Add a new
moonraker-configMonarch language and refactor theklipper-configMonarch language to better match each parser’s comment rules. - Extend folding ranges, document symbols, and code lens workers/providers to handle both
klipper-configandmoonraker-config. - Remove TextMate/theme conversion tooling and generated theme JSONs; define Monaco themes inline.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/convertTheme.mjs | Removed the VSCode→TextMate→Monaco theme conversion script. |
| src/workers/monacoFoldingRangesWorker.ts | Improves config folding detection (whitespace-tolerant headers/regions + SAVE_CONFIG folding) and adds Moonraker support. |
| src/workers/monacoDocumentSymbolsWorker.ts | Makes section/property detection whitespace-tolerant and enables Moonraker support. |
| src/workers/monacoCodeLensWorker.ts | Makes section detection whitespace-tolerant and enables Moonraker support. |
| src/monaco/theme/editor.theme.json | Removed generated theme JSON. |
| src/monaco/theme/editor.light.theme.json | Removed generated light theme JSON. |
| src/monaco/theme/editor.dark.theme.json | Removed generated dark theme JSON. |
| src/monaco/theme/base.theme.light.json | Removed base VSCode light theme source JSON. |
| src/monaco/theme/base.theme.dark.json | Removed base VSCode dark theme source JSON. |
| src/monaco/language/tmLanguage.json | Removed TextMate schema JSON. |
| src/monaco/language/moonraker-config.monarch.ts | Adds Monarch tokenizer/config for Moonraker configs. |
| src/monaco/language/klipper-config.monarch.ts | Replaces previous highly-specialized tokenizer with parser-aligned config handling (comments/sections/keys/values). |
| src/monaco/README.md | Removed Monaco TextMate/theme conversion credits doc. |
| src/components/widgets/filesystem/setupMonaco.ts | Registers Moonraker language, registers providers for both config languages, and defines themes inline. |
| src/components/widgets/filesystem/monacoProviders.ts | Passes model language id through to workers so providers work for both config languages. |
| package.json | Removes the theme converter dev dependency. |
| package-lock.json | Removes the theme converter and its transitive deps from the lockfile. |
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/workers/monacoDocumentSymbolsWorker.ts:26
- The updated section regex allows leading whitespace, but
state.current.nameis set tosection[0], which will now include that indentation (e.g.' [printer]'). This will surface in the document symbol list. Consider capturing just the bracketed header (or trimming leading whitespace) when setting the symbol name.
const section = /^\s*\[[^\]]+\]/.exec(lineContent)
if (section) {
state.result.push(state.current = {
name: section[0],
range: {
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
src/workers/monacoFoldingRangesWorker.ts:224
- In
commentBlocks, blank lines currently don't clearstate.current, so comment folding can bridge across empty lines even though the docs describe folding “consecutive comment lines”. Consider settingstate.current = undefinedwhenlineContent.length === 0to ensure blank lines break comment blocks.
lineContent = lineContent.trim()
if (lineContent.length > 0) {
const isComment = /^\s*(?:;|#(?!region\b|endregion\b|\*#))/.test(lineContent)
if (isComment) {
if (state.current) {
state.current.end = index + 1
} else {
state.result.push(state.current = {
kind: 'comment',
start: index + 1,
end: index + 1
})
}
} else {
state.current = undefined
}
}
src/workers/monacoDocumentSymbolsWorker.ts:26
sectionnow matches leading whitespace, butname: section[0]will include that indentation in the outline (e.g. " [printer]"). Consider trimming the matched header (or building the name from the bracket contents) so document symbol names are stable regardless of indentation.
const section = /^\s*\[[^\]]+\]/.exec(lineContent)
if (section) {
state.result.push(state.current = {
name: section[0],
range: {
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 19 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/workers/monacoDocumentSymbolsWorker.ts:26
- The section regex now includes leading whitespace ("^\s*[") and the symbol name uses
section[0], so indented section headers will show up in the outline with leading spaces (e.g. " [foo]"). Consider capturing just the bracketed header (or trimming the match) when settingnameso symbols render consistently.
const section = /^\s*\[[^\]]+\]/.exec(lineContent)
if (section) {
state.result.push(state.current = {
name: section[0],
range: {
Improves the monaco editor light and dark themes, the monarch language definition for Klipper and Moonraker config files, removes obsolete textmate related files.