I’m using Visual Studio Code with the Gruvbox theme. I have the following configuration in my settings.json
:
"editor.tokenColorCustomizations": {
"[Gruvbox Dark Medium]": {
"textMateRules": [
{
"scope": "source.c, entity.name.function.preprocessor",
"settings": {
"foreground": "#eb9b82"
}
}
]
}
},
This colors C macros differently than the default. This works as expected, except that if I open a Rust file, Rust macros are also colored differently, despite the source.c
in the scope
field. How can I have this settings apply only to C files? Rust macros have the exclamation mark at the end which differentiate them from regular function, I don’t a different color for them.
EDIT:
Here is what the VSCode token inspector shows without the above settings for the println!
macro:
Here is what the VSCode token inspector shows with the above settings enabled:
2
Answers
As Mark noticed, you have a comma between your two things. You wanted a descendent selector, but you turned it into grouping. See https://macromates.com/manual/en/scope_selectors. Remove the comma.
You could just use semantic highlighting customization instead?
You were close with your original attempt. Try this instead:
The comma between scopes makes them
alternatives
so the rule is being applied tosource.c
and toentity.name.function.preprocessor
separately.But you want to modify (i.e., limit) the scopes – in that case you do not use a comma to separate the scopes but just a space.
[I can’t actually duplicate your language/macro environment so I can’t test this as I usually do.]