In VS Code, I am looking for a way to enforce the usage of a specific Textmate rule, overriding what VS Code uses instead of the one that I would like it to use.
My VS Code version is:
Version: 1.63.0
Commit: 7db1a2b88f7557e0a43fec75b6ba7e50b3e9f77e
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
In my settings.json, I have custom color overrides for various Textmate scopes.
In particular, I have this snippet and its purpose is to enforce the usage of color black for attribute names ("variables") unless it is an f-string, in which case I would like to for the entire f-string to be green. Note that I would like for the whole of the f-string to be green (not the "f" letter, however) - no matter if it contains attribute access or not.
{
"scope": [
"meta.member.access.python",
],
"settings": {
"foreground": "#000",
"fontStyle": ""
}
},
{
"scope": [
"meta.fstring.python",
],
"settings": {
"foreground": "#007f00",
"fontStyle": "italic"
}
},
Instead, what I am getting is on the screenshot below, where you can see that self.hello is still black and, upon checking what Textmate rules match these elements, I see that it is meta.member.access.python indeed.
VS Code Textmate rules f-strings
The question is how I can achieve what I am looking for?
Either a way to ignore other rules when I am in an f-string or a way to somehow combine the rules, e.g. use specific settings for meta.member.access.python only when it is within an f-string?
Thank you.
CodePudding user response:
{
"scope": [
"meta.fstring.python constant.character.format.placeholder.other.python",
"meta.fstring.python variable.language.special.self.python",
"source.python meta.fstring.python string.interpolated.python string.quoted.single.python",
"meta.fstring.python"
],
"settings": {
"foreground": "#00ff0d",
"fontStyle": "italic"
}
},
I can not reproduce your status, I don't know which Color Theme you are using, and the different color themes will modify the scope and color it. But you can override it like the above example.
