Repository navigation
Conversation
Confidence Score: 4/5
[Medium impact] The changes affect the editor workflow for Nim files. The PR appears safe to merge, with two non-blocking highlighting fixes recommended. FindingsSummaryAdds a Nim language mode and registers
Reviews (1) · Last reviewed commit: "fix: restore Nim syntax highlighting and..." · Reviewed by Greptile |
| state.inTripleString = true; | ||
| return readTripleString(stream, state); | ||
| } | ||
| if (stream.match('"')) return readString(stream); |
There was a problem hiding this comment.
For valid Nim such as let path = r"C:\" # note, the prefix is read separately, then readString treats the backslash as escaping the closing quote. The trailing comment is colored as part of the string. Recognize raw and generalized string prefixes before applying ordinary string escapes, and add a regression test.
| if (stream.match("#[")) { | ||
| state.blockCommentDepth = 1; | ||
| return readBlockComment(stream, state); | ||
| } | ||
| if (stream.match("#")) { |
There was a problem hiding this comment.
Nim uses ##[ ... ]## for multiline documentation comments, but ##[ fails the #[ check and falls into the single-line comment branch. The following documentation lines are then colored as code. Recognize documentation comment delimiters before the line-comment branch, track their matching closer, and test a multiline example.
Signed-off-by: jay23606 <4602056+jay23606@users.noreply.github.com>
Bug
Nim files are no longer highlighted, and Nim is missing from the syntax menu. The Ace editor's Nim mode was not carried over when the editor moved to CodeMirror, and
@codemirror/language-datadoes not bundle Nim.Change
src/cm/modes/nim/index.ts: aStreamLanguagetokenizer for Nim covering line and block comments (including nested#[ ]#), triple-quoted and regular strings, numeric literals, keywords, atoms and builtin types.src/cm/supportedModes.ts: registers theNimmode for.nim,.nimsand.nimblefiles, so it appears in the syntax menu.tests/unit/nimHighlighting.test.ts: checks that.nimresolves to theNimcaption, and that the tokenizer colours keywords, types, numbers, strings and comments.Testing
npx vitest run tests/unit/nimHighlighting.test.tspasses (2 tests).expected 'Plain Text' to be 'Nim', and the tokenizer test fails because the Nim module is missing.npx biome check src/cm/modes/nim/index.ts src/cm/supportedModes.ts tests/unit/nimHighlighting.test.tspasses.Regression test: fails on base twice (/expected 'Plain Text' to be 'Nim'/), passes on fix twice (
npx vitest run tests/unit/nimHighlighting.test.ts)Fixes #3014