vim-python / python-syntax

Python syntax highlighting for Vim
MIT License
438 stars 84 forks source link

ENH: Better highlightling for raw strings #39

Closed has2k1 closed 6 years ago

has2k1 commented 6 years ago

Github's highlighting of raw strings makes regexes more readable. For example:

var =  '^[a-zA-Z0-9]+([^\s\w\d])*\W{3,4}\[\]|(?:abc.+)\1$'  # not highlighted
var = r'^[a-zA-Z0-9]+([^\s\w\d])*\W{3,4}\[\]|(?:abc.+)\1$'  # highlighted

The above regex may not give the full picture, but we make some sense of the highlighting. You have four colours for:

nfnty commented 6 years ago

IMO glancing at the code should immediately make it clear where strings are located. Doing something like you propose will make that much harder.

has2k1 commented 6 years ago

I have since thought about this and I think the best place for it is in a custom after/syntax/python.vim. There isn't a nice way to do it that would make it portable across different themes. Plus there may be performance implications as vim warns about using look-around regexes, and they would be indispensable for this task.

I will implement this for myself and put the code up somewhere.