Reputation: 21
I'm trying to change method calls color in VSCode. I know I can change the Function scope color as follewed:
{
"name": "Function call",
"scope": "meta.function-call.object",
"settings": {
"foreground": "#e26f60"
}
}
Is there an equivalent for method calls. I would like to only highlight the foo_method() in the following code:
class Foo():
def foo_method(self):
print("Called Foo from class")
foo_object = Foo()
foo_object.foo_method()
Upvotes: 2
Views: 1576
Reputation: 21
I know two ways to do it for python, it might give you an idea: setting a text mate theming rule is not beginner friendly to play around. Best way imo to open users/username/.vscode/extensions folder. And search the your favorite theme you want to edit. Make a backup of the file and play around. Most of them doesn't have specific code for method call. But you can add following to your code for method calls and change to hex color value with your preferred color.
{
"scope": "meta.function-call.generic.python",
"settings": {
"foreground": "#fad599",
"fontStyle": ""
}
},
Upvotes: 0
Reputation: 65463
The scope of the method call to foo_method
is:
meta.function-call.generic.python
meta.function-call.python
meta.member.access.python
source.python
So to just target methods, try using a more specific scope selector in your theme. For example, meta.member.access meta.function-call
will select all meta.function-call
scopes under meta.member.access
scopes:
{
"name": "Function call",
"scope": "meta.member.access meta.function-call",
"settings": {
"foreground": "#e26f60"
}
}
(you may need to further tweak the scope selector based on your specific needs)
Upvotes: 1