[quote=“agibsonsw”]I see now what you were indicating with self, cls . In a line such as
self.window.focus_view(OrderedFilesCommand.file_views[index][1])
focus_view is my chosen colour, but self and index are no longer the colour they should be. My expression
<string>(?:[a-zA-Z_][a-zA-Z0-9_]*\.)*(append|lower|sort|split|itemgetter)\s*(?=\()</string>
is not sufficient to discount everything else on the line.
Can you elaborate on “I just don’t scope them with anything” please? This should help me…
[/quote]
This is what I was trying to say earlier. I already accounted for all of the stuff, so I was suggesting that you leverage the work I already did.
Basically in my version I don’t do this (?:[a-zA-Z_][a-zA-Z0-9_].). This will greedily include any parent object that happens to come before your target. That is the way it was doing things before I touched it. If an object had a function in it, all preceding object members got pulled into the scope which I though overzealous. So what I did is change the default function check to not greedily include those members, and then I catch them with this and give them no additional scope (I should probably check for lists here as well):
<key>generic_object_names</key>
<dict>
<key>match</key>
<string>(\.\b([A-Za-z_][A-Za-z0-9_]*)\b(?!\()|\b([A-Za-z_][A-Za-z0-9_]*)\b\.)</string>
</dict>
So you can see here I look for built in things first, and if I don’t find those, I throw out all the dot members that aren’t function calls etc, then I check for API and then functions, and then lists etc.:
<dict>
<key>include</key>
<string>#builtin_functions</string>
</dict>
<dict>
<key>include</key>
<string>#builtin_types</string>
</dict>
<dict>
<key>include</key>
<string>#magic_function_names</string>
</dict>
<dict>
<key>include</key>
<string>#language_variables</string>
</dict>
<dict>
<key>include</key>
<string>#generic_object_names</string>
</dict>
<dict>
<key>include</key>
<string>#st2_api</string>
</dict>
<dict>
<key>begin</key>
<string>(?:\.)?([a-zA-Z_][a-zA-Z_0-9]*)\s*(?=\()</string>
<key>beginCaptures</key>
I think I also made some minor adjustments to ensure that scope and built in globals get highlighted correctly too, but I would have to diff my changes to remember what I did.
[quote=“agibsonsw”]**
Not so silly now eh? [/quote]