I tried using both Python3/PythonImproved .tmLanguage syntaxes, but neither does this for some reason. Are those actually supposed to be the same color as variables in most editors?
Here's a screenshot of some random function:
And here's how I want it to look like:
To sum it up I just want everything called with parentheses like function() or an object.method() to be highlighted.
I used ScopeHunter to find out the scope of those calls and they are the same function-call.generic.python calls that are actually differentiated from object instances/variables in PythonImproved .tmLanguage, though not a single theme file did anything with this scope.
So I added this rule to my color scheme file (.tmTheme):
I'm the author of Python Improved. Sublime's default Monokai theme lacks the ability to highlight many of the scopes in PI (as well as a bunch of other languages - it's quite bare-bones). One of my other projects, the Neon Color Scheme, contains rules for all of PI's new scopes, as well as scopes for a number of other languages, both built-in and third-party from Package Control. If you don't like the colors, I've tried to keep
Neon.tmTheme
pretty organized, so you should be able to adapt the rules as you wish. If you have any questions or problems, feel free to submit an issue forPython Improved
orNeon
.Yes that is intended. In Python all variables you declare are bindings to objects. This means if you declare a variable
varA = 1
then the object1
will be created and the namevarA
will be bound to this object. When you declare nextvarB = 1
thenvarB
will be bound to the same object asvarA
. This you can check with the built-in functionid
which returns the id of the object the variable is bound to:id(varA) == id(varB) # True
.The same is for functions and instance methods. If you declare a function
then an object will be created which represents that function. At the same time the name
foo
is bound to that object. Declaringbar = foo
will allow for a call of the previously created function object through bar:bar()
will produce the same output asfoo()
(and call - or better use - the exactly same object in memory).For instance methods this is similar. Declaring a class
will create the required objects and bind
Foo
to the class andfoo
to the instance method of that class. DeclaringFoo.bar = Foo.foo
will allow forSo every 'variable' in python is in fact the binding of a name to an object and this holds for everything, including functions and instance methods. This is why they have the same (missing) syntax highlighting in most editors.