Skip to content

Add highlight for extra operators #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ let g:python_highlight_all = 1
| `g:python_highlight_space_errors` | Highlight trailing spaces | `0` |
| `g:python_highlight_doctests` | Highlight doc-tests | `0` |
| `g:python_highlight_class_vars` | Highlight class variables `self` and `cls` | `0` |
| `g:python_highlight_extra_operators` | Highlight extra operators | `0` |
| `g:python_highlight_all` | Enable all highlight options above, except for previously set. | `0` |
| `g:python_highlight_file_headers_as_comments` | Highlight shebang and coding headers as comments | `0` |
| `g:python_slow_sync` | Disable for slow machines | `1` |
Expand Down
9 changes: 7 additions & 2 deletions syntax/python.vim
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ if s:Enabled('g:python_highlight_all')
call s:EnableByDefault('g:python_highlight_doctests')
call s:EnableByDefault('g:python_print_as_function')
call s:EnableByDefault('g:python_highlight_class_vars')
call s:EnableByDefault('g:python_highlight_extra_operators')
endif

"
Expand Down Expand Up @@ -81,6 +82,9 @@ syn keyword pythonImport import
syn match pythonIdentifier '\v[a-zA-Z_][a-zA-Z0-9_]*' nextgroup=pythonFunctionArgs
syn match pythonRaiseFromStatement '\<from\>'
syn match pythonImport '^\s*\zsfrom\>'
if s:Enabled('g:python_highlight_extra_operators')
syn match pythonExtraOperator '[-+\*/%<>^&|~!=]' display
endif



Expand All @@ -97,10 +101,10 @@ else
syn match pythonStatement '\<async\s\+def\>' nextgroup=pythonFunction skipwhite
syn match pythonStatement '\<async\s\+with\>'
syn match pythonStatement '\<async\s\+for\>'
syn cluster pythonExpression contains=pythonStatement,pythonRepeat,pythonConditional,pythonOperator,pythonNumber,pythonHexNumber,pythonOctNumber,pythonBinNumber,pythonFloat,pythonString,pythonBytes,pythonBoolean,pythonBuiltinObj,pythonBuiltinFunc
syn cluster pythonExpression contains=pythonStatement,pythonRepeat,pythonConditional,pythonOperator,pythonExtraOperator,pythonNumber,pythonHexNumber,pythonOctNumber,pythonBinNumber,pythonFloat,pythonString,pythonBytes,pythonBoolean,pythonBuiltinObj,pythonBuiltinFunc
endif

syn region pythonFunctionArgs start='('rs=s+1 end=')'re=e-1 contains=pythonFunctionArgs,pythonFunctionKwargs,pythonRepeat,pythonClassVar,pythonConditional,pythonComment,pythonOperator,pythonNumber,pythonNumberError,pythonFloat,pythonHexNumber,pythonStatement,pythonOctNumber,pythonString,pythonRawString,pythonUniString,pythonExClass,pythonUniRawString,pythonNumber,pythonRawString,pythonBytes,pythonBuiltinObj,pythonNone,pythonBuiltinFunc,pythonBoolean nextgroup=pythonRaiseFromStatement display contained
syn region pythonFunctionArgs start='('rs=s+1 end=')'re=e-1 contains=pythonFunctionArgs,pythonFunctionKwargs,pythonRepeat,pythonClassVar,pythonConditional,pythonComment,pythonOperator,pythonExtraOperator,pythonNumber,pythonNumberError,pythonFloat,pythonHexNumber,pythonStatement,pythonOctNumber,pythonString,pythonRawString,pythonUniString,pythonExClass,pythonUniRawString,pythonNumber,pythonRawString,pythonBytes,pythonBuiltinObj,pythonNone,pythonBuiltinFunc,pythonBoolean nextgroup=pythonRaiseFromStatement display contained
syn match pythonFunctionKwargs /\i\+\ze=/ display contained
"
" Decorators (new in Python 2.4)
Expand Down Expand Up @@ -400,6 +404,7 @@ if v:version >= 508 || !exists('did_python_syn_inits')
HiLink pythonRepeat Repeat
HiLink pythonException Exception
HiLink pythonOperator Operator
HiLink pythonExtraOperator Operator

HiLink pythonDecorator Define
HiLink pythonDottedName Function
Expand Down