vim-python / python-syntax

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

Few proposals #7

Closed monkoose closed 7 years ago

monkoose commented 7 years ago

First

Can we add some variable to enclose new(different from hdima/python-syntax) self and cls in if statement? So people who do not need them can easily disabable their highlight. Myself i actually use this highlight, but we need to think about all users.

Second

Do you mind adding extra operators highlight group which you can find in klen/python-mode syntax. It looks like this

syn match pythonExtraOperator "\%([~!^&|/%+-]\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|=\@<!>\|\.\.\.\|\.\.\|::\)"
syn match pythonExtraPseudoOperator "\%(-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!=\)"
syn match pythonExtraOperator "\%(=\)"
syn match pythonExtraOperator "\%(\*\|\*\*\)"

HiLink pythonExraOperator    Operator
HiLink pythonExtraPseudoOperator   Operator

You can check more at https://github.com/python-mode/python-mode/blob/develop/syntax/python.vim I think with variable too, so people who need to highlght => == etc, can turn them on.

Thank you.

nfnty commented 7 years ago

PRs are welcome.

monkoose commented 7 years ago

Ok, will add it tomorrow.

monkoose commented 7 years ago

I made PR for self_cls proposal. But the second one is more complecated and needs some discussion. Should we add just one variable for all this signs? Or should we break them into few variables for more control? Something like g:python_highlight_equal_operator g:python_highlight_bitwise_operators g:python_highlight_comparison_operators etc?

And btw, I had this in my syntax for a long time and never had any issue

syn match pythonExtraOperator "\%([~!^&|/%+-]\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|=\@<!>\|\.\.\.\|\.\.\|::\)"
syn match pythonExtraPseudoOperator "\%(-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!=\)"
syn match pythonExtraOperator "\%(=\)"
syn match pythonExtraOperator "\%(\*\|\*\*\)"

But now when i'm actually trying to understand what is going on, i'm not so sure what is going on at the first line. There is operators like === =~ :: etc. Do i not understand something? Any thoughts? Does even someone need operators highlight besides me?

nfnty commented 7 years ago

Only add builtin operators and group them under one option.

monkoose commented 7 years ago

Ok. Should * and ** to be highlighted in FunctionParameters for *args and **kwargs? Should their highlight be the same as for multiplication and power operators for simplicity?

nfnty commented 7 years ago

Yeah.

monkoose commented 7 years ago

Ok.