Repository navigation
syntax: add Typst - #4243
Open
Londopy wants to merge 3 commits into
Open
syntax: add Typst#4243Londopy wants to merge 3 commits into
Londopy wants to merge 3 commits into
Conversation
Andriamanitra
suggested changes
Sep 23, 2026
Andriamanitra
left a comment
Collaborator
There was a problem hiding this comment.
I think this is a good approach and I didn't notice any issues with the syntax. It only highlights the basics but it still helps, and having it allows filetype-specific configuration -- speaking of which we should add typst to the built-in comment plugin as well.
Comment on lines
+12
to
+14
| # headings in markup mode. No leading whitespace is allowed: rules are | ||
| # also matched against the rest of a line after inline math, raw text | ||
| # etc., so "$x$ = 5" would otherwise look like a heading. |
Collaborator
There was a problem hiding this comment.
The regex explains itself better than this comment does.
Contributor
Author
|
Thanks! Added typst ( |
Andriamanitra
approved these changes
Sep 24, 2026
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.
Adds
typst.yamlfor.typfiles, following the subset @Andriamanitra outlined in #4064 (thanks to @TinCan2 for that PR). Typst switches between markup, code and math mode at any point, which micro's rules can't track, so this only highlights what looks the same in every mode://and/* */comments\u{...}$...$) and the name that starts a code expression (#set,#emph,#z.at)No keywords and no single-quoted strings. The heading and math groups follow the attempt in #2780.
Three things needed care:
\$and\#don't start math or a code expression (micro picks the region that starts first, and the escape starts at the backslash). That's what makes math and#...safe to include. It also ends at the end of the line, since a trailing\is a line break.//after:isn't a comment, so URLs aren't commented out. Same idiomtex.yamluses for\%.=in column 0. Rules also run on the rest of a line after inline math or raw text, so$x$ = 5would otherwise be highlighted as a heading.Known limitations: indented headings aren't highlighted, text after inline math in a heading loses the heading color, and nested block comments end at the first
*/.Tested with the example from #2780 (nothing in it is highlighted incorrectly) and a file of edge cases, through both
HighlightStringand the editor's incremental path, with and without #4022, and in the built editor. Editing lines that open or close math, raw blocks, strings and comments re-highlights the same as highlighting the file fresh.Closes #2780