This extension provides a TextMate grammar for Rust. This grammar is used for VS Code's built-in Rust syntax highlighting (source).
Issues and PRs should be submitted here, and VS Code syncs this repo regularly.
The semantic highlighting provided by Rust Analyzer is more precise than this grammar. For example, semantic highlighting can easily distinguish enums, structs, and traits.
For best results, install Rust Analyzer to benefit from both.
Rust Syntax is compatible with Rust Analyzer, but the scopes provided
by this extension will not be visible while semantic highlighting is
enabled. If for some reason you would like to disable semantic
highlighting, you can do this in your settings.json
:
"[rust]": {
"editor.semanticHighlighting.enabled": false
}
Not all themes are specifically optimized for Rust.
We have tried to provide sensible default scopes that will work with most themes.
If you want to modify the colors in a particular theme, you can do so in your settings.json
:
"editor.tokenColorCustomizations": {
"[Theme Name]": {
"textMateRules": [
{
"scope": "variable.other.rust",
"settings": {
"foreground": "#ffff00"
}
}
]
}
}
The VS Code command Developer: Inspect Editor Tokens and Scopes
will show you the scope stack at the current cursor position.
The grammar is maintained as YAML, using tasks to generate JSON on save (please don't edit the JSON grammar directly).
You can regenerate the JSON manually from the command palette using
Tasks: Run Build Task
, or running gulp yaml
in a terminal.