The sample renderings used VS Code's Dark+, which renders many scopes identically, so a grammar change often doesn't show up in the images. Dark+ gives the 42 scope stacks the samples produce 10 distinct renderings: types, namespaces, builtin types and classes share one color, and operators and separators stay at the default foreground, so a rule that moved a token between them changed nothing visible. `render_sample.py` now uses its own palette. Each family of related scopes, such as the numeric literals, gets one color, and bold and italic distinguish the scopes within a family; the renderer now emits font styles to support this. The samples' 34 scopes get 32 renderings; only the two embedded C++ spellings and a string's opening and closing quotes share one. Unscoped text is dimmer than any scope's color, so `0o8` renders as an octal `0o` followed by an unscoped `8`. The colors are Catppuccin Mocha's, and each has at least 4.4:1 contrast against the background. No existing theme does this: across 264 theme files, the 19 VS Code built-ins plus 30 popular extensions, the best renders 19 of the 42 stacks distinctly. Assisted-by: Claude Code
Textmate Language Definition
This directory contains a TextMate bundle which can be used in various editors such as TextMate, Atom, or the IntelliJ family for syntax highlighting of Carbon source files.
If you are using TextMate, see the documentation on
how to install TextMate bundles.
Clone the repository with Git and symlink/copy the utils/textmate directory to
any of the paths TextMate will search through (you can find these paths in the
TextMate documentation above).
IntelliJ
If you are using IntelliJ or a IntelliJ Platform product, you can find
documentation on
how to install TextMate bundles in IntelliJ.
Clone the repository with Git and open the utils/textmate directory inside the
IntelliJ TextMate Bundle window.
Atom
If you are using Atom, you can convert the bundle to an Atom-compatible one. See the Atom documentation on how to do that.
Other
For other editors that support TextMate bundles you can consult your editors documentation to see how to use the bundle.
Samples
Samples/ holds Carbon sources that exercise the grammar, each with an SVG
rendering of the scopes this bundle gives it. Some deliberately contain invalid
code, to show that highlighting stays sensible while something is being typed.
The renderings are generated, not screenshotted, so they always reflect the grammar in this repository. Regenerate them in the same commit as any change to the grammar, so a reviewer can see what the change does to real code:
utils/textmate/render_sample.py utils/textmate/Samples/*.carbon
The colors are a palette built for this grammar rather than an editor's theme. Each family of related scopes gets one color, and bold and italic distinguish the scopes within a family, so every scope the grammar emits renders differently and a change to what the grammar scopes is visible in the image. Unscoped text is dimmer than any scope's color, so text the grammar misses stands out. A scope with no entry of its own takes its family's color and style, so give a new scope an entry to keep every scope distinct.