refactor: improve Monaco language definitions#1832
Merged
pedrolamas merged 19 commits intoMay 9, 2026
Conversation
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Monaco Monarch language definitions for G-code, Klipper config, and Moonraker config, aligning folding + theming with the new token scopes and adding unit tests to pin tokenizer behavior.
Changes:
- Refined Monarch tokenization rules for
gcode,klipper-config, andmoonraker-config(including new token categories used by themes). - Updated folding-range worker logic for region markers, comments, and SAVE_CONFIG handling.
- Added Vitest tokenizer tests (plus jsdom polyfills) and updated documentation to reflect the new highlighting behavior.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/setup.ts | Adds jsdom polyfills required for loading Monaco in unit tests. |
| src/workers/monacoFoldingRangesWorker.ts | Updates folding detection regexes to better match the new language definitions (regions/comments/SAVE_CONFIG). |
| src/monaco/language/gcode.monarch.ts | Reworks G-code tokenization to use new command/param/macro/message token scopes. |
| src/monaco/language/klipper-config.monarch.ts | Refactors config tokenization state flow (initial vs in-section) and SAVE_CONFIG token handling. |
| src/monaco/language/moonraker-config.monarch.ts | Refactors config tokenization state flow (initial vs in-section) to match Moonraker parsing behavior. |
| src/monaco/language/tests/tokenize-helper.ts | Adds shared helpers for registering languages and asserting token streams. |
| src/monaco/language/tests/gcode.monarch.spec.ts | Adds behavior-confirmation tests for the new G-code tokenizer. |
| src/monaco/language/tests/klipper-config.monarch.spec.ts | Adds behavior-confirmation tests for the Klipper config tokenizer. |
| src/monaco/language/tests/moonraker-config.monarch.spec.ts | Adds behavior-confirmation tests for the Moonraker config tokenizer. |
| src/components/widgets/filesystem/setupMonaco.ts | Extends Monaco theme rules to style the new token scopes. |
| public/editor.theme.json | Removes the previously committed theme JSON asset. |
| docs/docs/features/file-editor.md | Updates user-facing docs to reflect the new highlighted elements. |
| CLAUDE.md | Documents the new tokenizer test location/helpers and the Monaco jsdom polyfills. |
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improves the Gcode, Klipper config, and Moonraker config monarch language definitions, also adds behavior confirmation tests.
Updates the Monaco themes to match the new definitions.
Updates the Monaco folding provider to match the new definitions.