I’m making a custom syntax highlighting theme for my VS Code. I’ve chosen to do it the simplest way, in the settings.json
. I know it’s not the best way to do this, but it’s more than enough for my purposes. I’m mostly going to be using this with C/C++, clangd and CMake. The setup for this is pretty simple:
"editor.semanticHighlighting.enabled": true, // I don't exactly remember why, but everyone says to do this
"editor.tokenColorCustomizations":
{
"textMateRules": // Token customizations go here
[
{
"scope" :
[
"keyword.control.directive.conditional.if.cpp" // Example for #if
],
"settings":
{
"foreground": "#f00",
"fontStyle": "bold italic strikethrough"
}
}
]
},
"workbench.colorCustomizations":
{
"foreground": "#f00" // UI theme goes here
}
While this works fine, I cannot really understand what to put in the "scope"
key. I used Developer: Inspect Editor Tokens and Scopes
to see what tokens my code uses, and it shows a bunch of strings under textmate scopes
. I’ve seen in the official C/C++ Themes Extension from Microsoft, they put multiple tokens in one, e. g. source.cpp keyword.operator.new"
. So I thought maybe it’s like a CSS selector and tried that, but it didn’t work. I also couldn’t find a complete list of all possible scope tokens, and I think it’s because every language adds their own.
The questions are:
- How do I form a
"scope"
value? What are the syntax rules for these? - Is there any way to view all possible tokens (all of these
scope.cpp
andkeyword.operator.new
etc.)?