There are a couple of advantages to what my version does over yours. There were a number of changes to make sure self and cls still get scoped proper in lines like this:
self.object.api_call()
self and cls donât get colored in the theme, but they are getting scoped, and my requirement was not to break any other scoping. The one thing I did change was that if you had this:
self.object.another_object.function()
object.another_object.function() would all get scoped as meta.function-call. I found this to be overzealous, so I reduced it to only scope function() as meta.function-call. After that, all I did was add generic to the function call so that all was pretty much the same meta.function-call.generic, but you add an extra specifier you could target it in your theme, but you donât have to and it would then be unhighlighted and benign.
By inserting the api check right before the normal function check, you get two kinds of function calls to target (keep in mind, built in functions are not touched by these, so they still get scoped like normal; I think I might have made some adjustments to ensure this).
meta.function-call.generic.python and meta.function-call.st2-api.python
I highlight like this if all I want to highlight is the api:
<dict>
<key>name</key>
<string>Function Call</string>
<key>scope</key>
<string>meta.function-call.st2-api</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#A6E22E</string>
</dict>
</dict>