Skip to content

Add Odin syntax highlighting#863

Open
santerijps wants to merge 1 commit into
microsoft:mainfrom
santerijps:odin-syntax-highlighting
Open

Add Odin syntax highlighting#863
santerijps wants to merge 1 commit into
microsoft:mainfrom
santerijps:odin-syntax-highlighting

Conversation

@santerijps
Copy link
Copy Markdown

@santerijps santerijps commented May 15, 2026

Syntax highlighting support for Odin

This PR adds syntax highlighting for the Odin programming language.

  • ADD Odin syntax definition odin.lsh and highlighting test odin.odin
  • UPDATE markdown.lsh to handle Odin code blocks and markdown.md highlighting test

Test Screenshots

odin.odin

How to replicate:

cargo run -p lsh-bin -- render --input .\assets\highlighting-tests\odin.odin .\crates\lsh\definitions\

odin-4 odin-2

markdown.md

How to replicate:

cargo run -p lsh-bin -- render --input .\assets\highlighting-tests\markdown.md .\crates\lsh\definitions\

odin-3

Copilot AI review requested due to automatic review settings May 15, 2026 11:14
@santerijps
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 #+feature is 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.

Comment thread crates/lsh/definitions/odin.lsh Outdated
Comment thread assets/highlighting-tests/odin.odin Outdated
Comment thread crates/lsh/definitions/markdown.lsh
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread crates/lsh/definitions/odin.lsh Outdated
Comment thread assets/highlighting-tests/odin.odin Outdated
Comment thread crates/lsh/definitions/markdown.lsh Outdated
@santerijps
Copy link
Copy Markdown
Author

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 like 0..<10 by consuming 0. 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 .5 if 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;
            }

Comment thread crates/lsh/definitions/odin.lsh Outdated
Comment thread crates/lsh/definitions/odin.lsh Outdated
Comment thread assets/highlighting-tests/odin.odin Outdated
Comment on lines 70 to +82
if /.*/ {}
}
}
} else if /(?i:odin)/ {
loop {
await input;
if /\s*```/ {
return;
} else {
odin();
if /.*/ {}
}
}
@santerijps santerijps marked this pull request as draft May 15, 2026 12:21
@santerijps santerijps closed this May 15, 2026
@santerijps santerijps reopened this May 15, 2026
@santerijps santerijps force-pushed the odin-syntax-highlighting branch from f53abcb to 3b4b9c3 Compare May 15, 2026 12:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 like 0..<10 (common in Odin), highlighting 0. 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;
            }

Comment thread crates/lsh/definitions/odin.lsh
Comment thread crates/lsh/definitions/markdown.lsh
@santerijps santerijps marked this pull request as ready for review May 15, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants