Add Odin syntax highlighting#863
Conversation
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
This PR adds Odin language syntax highlighting to the lsh highlighting system, including direct .odin file associations and Markdown fenced-code-block highlighting.
Changes:
- Added a new Odin language definition (
odin.lsh) with file association for**/*.odin. - Updated the Markdown highlighter to dispatch ```odin fenced blocks to the Odin highlighter.
- Added/updated highlighting test fixtures for Odin and Markdown.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| crates/lsh/definitions/odin.lsh | New Odin syntax definition and file association. |
| crates/lsh/definitions/markdown.lsh | Adds fenced-code-block dispatch for odin. |
| assets/highlighting-tests/odin.odin | New Odin highlighting fixture covering comments/strings/keywords/etc. |
| assets/highlighting-tests/markdown.md | Extends Markdown fixture with an odin fenced block. |
Comments suppressed due to low confidence (1)
crates/lsh/definitions/odin.lsh:43
- The directive matcher
/#\w+/won’t match Odin’s#+...directives (e.g. the test file starts with#+feature ...), so those tokens won’t be highlighted as keywords. Consider broadening the pattern to include#+(and any other directive prefixes you want to support) so#+featureis highlighted consistently with#assert,#partial, etc.
} else if /(?:true|false|nil)\>/ {
yield constant.language;
} else if /#\w+/ {
yield keyword.other;
} else if /@/ {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot apply changes based on the comments in this thread |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
crates/lsh/definitions/odin.lsh:50
- The numeric literal regex allows a trailing
.with no following digits ([\d_]+\.?[\d_]*), which will likely mis-tokenize Odin range expressions like0..<10by consuming0.as a number. Consider tightening the float alternatives so a decimal point is only matched when followed by at least one digit (and keep the leading-dot form like.5if desired).
} else if /(?i:-?(?:0x[\da-fA-F_]+|0b[01_]+|0o[0-7_]+|[\d_]+\.?[\d_]*|\.[\d_]+)(?:e[+-]?[\d_]+)?i?)/ {
if /\w+/ {
// Invalid numeric literal
} else {
yield constant.numeric;
}
| if /.*/ {} | ||
| } | ||
| } | ||
| } else if /(?i:odin)/ { | ||
| loop { | ||
| await input; | ||
| if /\s*```/ { | ||
| return; | ||
| } else { | ||
| odin(); | ||
| if /.*/ {} | ||
| } | ||
| } |
f53abcb to
3b4b9c3
Compare
3b4b9c3 to
d4dfbdd
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
crates/lsh/definitions/odin.lsh:57
- The numeric literal regex will consume the first
.in range expressions like0..<10(common in Odin), highlighting0.as a float and leaving the remaining.<to be parsed separately. Consider adjusting the float alternative to require at least one digit after the decimal point (or otherwise avoid matching a trailing.) so range operators aren’t partially consumed by the number matcher.
} else if /(?i:-?(?:0x[\da-fA-F_]+|0b[01_]+|0o[0-7_]+|[\d_]+\.?[\d_]*|\.[\d_]+)(?:e[+-]?[\d_]+)?i?)/ {
if /\w+/ {
// Invalid numeric literal
} else {
yield constant.numeric;
}
Syntax highlighting support for Odin
This PR adds syntax highlighting for the Odin programming language.
odin.lshand highlighting testodin.odinmarkdown.lshto handle Odin code blocks andmarkdown.mdhighlighting testTest Screenshots
odin.odinHow to replicate:
cargo run -p lsh-bin -- render --input .\assets\highlighting-tests\odin.odin .\crates\lsh\definitions\markdown.mdHow to replicate:
cargo run -p lsh-bin -- render --input .\assets\highlighting-tests\markdown.md .\crates\lsh\definitions\