Home Download Buy Blog Forum Support

Better Python syntax highlighting?

Better Python syntax highlighting?

Postby hangtwenty on Sun Apr 07, 2013 11:18 am

The Python syntax highlighting is really great. However, there's one aspect of it that drives me nuts. Once you do a function call of any sort - plain old function or a method call on something else - the entire chunk gets highlighted in a single color. Further, the arguments all get highlighted in a single color. This is hard to read, and also doesn't seem consistent with the highlighting for other languages.

To explain the problem more closedly ...
Code: Select all
foo = "something"

Currently `foo` and `bar` are colored with The Variable Color and `"something"` is in The String Color. But then if you do
Code: Select all

Now `foo`, `anything`, `bar`, `baz`, and `qux` are all colored with The Too-Common Color, a third-color that kind of washes over your Python code ... But shouldn't there be a little more variation here, a little more context? i.e. at least making the stuff inside parentheses be a different color, or coloring kwarg identifiers differently (i.e. `baz` above), coloriung the equal signs inside of parentheses the same color as equal signs in general ...

Does anybody feel the same about this, and/or know of a way to address it? Is it this way because of technical difficulty?
Posts: 2
Joined: Thu Feb 28, 2013 11:27 am

Re: Better Python syntax highlighting?

Postby skuroda on Sun Apr 07, 2013 9:26 pm

You can modify your theme file to apply different colors based on scope. How fine grained the context coloring is will rely on the tmLanguage file and what scopes are applied. You can use https://github.com/facelessuser/ScopeHunter to find what scopes are being applied in a given region. For example, function arguments (at least in python) apply the meta.function-call.arguments scope.

cursors.add(sublime.Region(region.begin(), region.begin() + len(new_content)))

I'm no expert at the theme stuff, so I've just been stumbling through making these modifications. I know a couple of people are working on color scheme editors, so perhaps you want to take a look at those
Posts: 692
Joined: Fri Oct 05, 2012 8:11 am

Re: Better Python syntax highlighting?

Postby hangtwenty on Wed Apr 10, 2013 12:30 pm

These are great tips, thanks so much.
Posts: 2
Joined: Thu Feb 28, 2013 11:27 am

Return to Ideas and Feature Requests

Who is online

Users browsing this forum: No registered users and 4 guests