@@ -53,6 +53,7 @@ if s:Enabled('g:python_highlight_all')
5353 call s: EnableByDefault (' g:python_highlight_doctests' )
5454 call s: EnableByDefault (' g:python_print_as_function' )
5555 call s: EnableByDefault (' g:python_highlight_class_vars' )
56+ call s: EnableByDefault (' g:python_highlight_operators' )
5657endif
5758
5859"
7374syn keyword pythonRepeat for while
7475syn keyword pythonConditional if elif else
7576syn keyword pythonException try except finally
76- syn keyword pythonOperator and in is not or
7777" The standard pyrex.vim unconditionally removes the pythonInclude group, so
7878" we provide a dummy group here to avoid crashing pyrex.vim.
7979syn keyword pythonInclude import
@@ -83,7 +83,6 @@ syn match pythonRaiseFromStatement '\<from\>'
8383syn match pythonImport ' ^\s *\z sfrom\> '
8484
8585
86-
8786if s: Python2Syntax ()
8887 if ! s: Enabled (' g:python_print_as_function' )
8988 syn keyword pythonStatement print
10099 syn cluster pythonExpression contains =pythonStatement,pythonRepeat,pythonConditional,pythonOperator,pythonNumber,pythonHexNumber,pythonOctNumber,pythonBinNumber,pythonFloat,pythonString,pythonBytes,pythonBoolean,pythonBuiltinObj,pythonBuiltinFunc
101100endif
102101
102+
103+ "
104+ " Operators
105+ "
106+ syn keyword pythonOperator and in is not or
107+ if s: Enabled (' g:python_highlight_operators' )
108+ syn match pythonOperator ' \V =\| -\| +\| *\| @\| /\| %\| &\| |\| ^\| ~\| <\| >\| !='
109+ endif
110+ syn match pythonError ' [$?]\|\( [-+@%&|^~]\)\1\{ 1,}\|\( [=*/<>]\)\2\{ 2,}\|\( [-=+*@/%&|^~<>]\)\3\@ ![-+*@/%&|^~<>]\| [<!>]\+ =\{ 2,}\| [<!>]\{ 2,}=\+ ' display
111+
103112"
104113" Decorators (new in Python 2.4)
105114"
@@ -127,10 +136,7 @@ syn keyword pythonTodo TODO FIXME XXX contained
127136" Errors
128137"
129138
130- syn match pythonError ' \<\d\+\D\+\> ' display
131- syn match pythonError ' [$?]' display
132- syn match pythonError ' [&|]\{ 2,}' display
133- syn match pythonError ' [=]\{ 3,}' display
139+ syn match pythonError ' \<\d\+ [^0-9[:space:]]\+\> ' display
134140
135141" Mixing spaces and tabs also may be used for pretty formatting multiline
136142" statements
@@ -275,34 +281,34 @@ endif
275281"
276282
277283if s: Python2Syntax ()
278- syn match pythonHexError ' \< 0[xX]\x *[g-zG-Z]\+\x *[lL]\=\> ' display
279- syn match pythonOctError ' \< 0[oO]\=\o *\D\+\d *[lL]\=\> ' display
280- syn match pythonBinError ' \< 0[bB][01]*\D\+\d *[lL]\=\> ' display
284+ syn match pythonHexError ' \< 0[xX]\x *[g-zG-Z]\+\x *[lL]\=\> ' display
285+ syn match pythonOctError ' \< 0[oO]\=\o *\D\+\d *[lL]\=\> ' display
286+ syn match pythonBinError ' \< 0[bB][01]*\D\+\d *[lL]\=\> ' display
281287
282- syn match pythonHexNumber ' \< 0[xX]\x\+ [lL]\=\> ' display
283- syn match pythonOctNumber ' \< 0[oO]\o\+ [lL]\=\> ' display
284- syn match pythonBinNumber ' \< 0[bB][01]\+ [lL]\=\> ' display
288+ syn match pythonHexNumber ' \< 0[xX]\x\+ [lL]\=\> ' display
289+ syn match pythonOctNumber ' \< 0[oO]\o\+ [lL]\=\> ' display
290+ syn match pythonBinNumber ' \< 0[bB][01]\+ [lL]\=\> ' display
285291
286292 syn match pythonNumberError ' \<\d\+\D [lL]\=\> ' display
287293 syn match pythonNumber ' \<\d [lL]\=\> ' display
288294 syn match pythonNumber ' \< [0-9]\d\+ [lL]\=\> ' display
289295 syn match pythonNumber ' \<\d\+ [lLjJ]\> ' display
290296
291- syn match pythonOctError ' \< 0[oO]\=\o *[8-9]\d *[lL]\=\> ' display
292- syn match pythonBinError ' \< 0[bB][01]*[2-9]\d *[lL]\=\> ' display
297+ syn match pythonOctError ' \< 0[oO]\=\o *[8-9]\d *[lL]\=\> ' display
298+ syn match pythonBinError ' \< 0[bB][01]*[2-9]\d *[lL]\=\> ' display
293299
294- syn match pythonFloat ' \.\d\+\% ([eE][+-]\=\d\+\)\= [jJ]\=\> ' display
295- syn match pythonFloat ' \<\d\+ [eE][+-]\=\d\+ [jJ]\=\> ' display
296- syn match pythonFloat ' \<\d\+\.\d *\% ([eE][+-]\=\d\+\)\= [jJ]\= ' display
300+ syn match pythonFloat ' \.\d\+\% ([eE][+-]\=\d\+\)\= [jJ]\=\> ' display
301+ syn match pythonFloat ' \<\d\+ [eE][+-]\=\d\+ [jJ]\=\> ' display
302+ syn match pythonFloat ' \<\d\+\.\d *\% ([eE][+-]\=\d\+\)\= [jJ]\= ' display
297303else
298- syn match pythonOctError ' \< 0[oO]\=\o *\D\+\d *\> ' display
304+ syn match pythonOctError ' \< 0[oO]\=\o *\D\+\d *\> ' display
299305 " pythonHexError comes after pythonOctError so that 0xffffl is pythonHexError
300- syn match pythonHexError ' \< 0[xX]\x *[g-zG-Z]\x *\> ' display
301- syn match pythonBinError ' \< 0[bB][01]*\D\+\d *\> ' display
306+ syn match pythonHexError ' \< 0[xX]\x *[g-zG-Z]\x *\> ' display
307+ syn match pythonBinError ' \< 0[bB][01]*\D\+\d *\> ' display
302308
303- syn match pythonHexNumber ' \< 0[xX][_0-9a-fA-F]*\x\> ' display
304- syn match pythonOctNumber ' \< 0[oO][_0-7]*\o\> ' display
305- syn match pythonBinNumber ' \< 0[bB][_01]*[01]\> ' display
309+ syn match pythonHexNumber ' \< 0[xX][_0-9a-fA-F]*\x\> ' display
310+ syn match pythonOctNumber ' \< 0[oO][_0-7]*\o\> ' display
311+ syn match pythonBinNumber ' \< 0[bB][_01]*[01]\> ' display
306312
307313 syn match pythonNumberError ' \<\d [_0-9]*\D\> ' display
308314 syn match pythonNumberError ' \< 0[_0-9]\+\> ' display
@@ -314,12 +320,12 @@ else
314320 syn match pythonNumber ' \<\d [jJ]\> ' display
315321 syn match pythonNumber ' \< [1-9][_0-9]*\d [jJ]\> ' display
316322
317- syn match pythonOctError ' \< 0[oO]\=\o *[8-9]\d *\> ' display
318- syn match pythonBinError ' \< 0[bB][01]*[2-9]\d *\> ' display
323+ syn match pythonOctError ' \< 0[oO]\=\o *[8-9]\d *\> ' display
324+ syn match pythonBinError ' \< 0[bB][01]*[2-9]\d *\> ' display
319325
320- syn match pythonFloat ' \.\d\% ([_0-9]*\d\)\=\% ([eE][+-]\=\d\% ([_0-9]*\d\)\=\)\= [jJ]\=\> ' display
321- syn match pythonFloat ' \<\d\% ([_0-9]*\d\)\= [eE][+-]\=\d\% ([_0-9]*\d\)\= [jJ]\=\> ' display
322- syn match pythonFloat ' \<\d\% ([_0-9]*\d\)\=\.\d\% ([_0-9]*\d\)\=\% ([eE][+-]\=\d\% ([_0-9]*\d\)\=\)\= [jJ]\= ' display
326+ syn match pythonFloat ' \.\d\% ([_0-9]*\d\)\=\% ([eE][+-]\=\d\% ([_0-9]*\d\)\=\)\= [jJ]\=\> ' display
327+ syn match pythonFloat ' \<\d\% ([_0-9]*\d\)\= [eE][+-]\=\d\% ([_0-9]*\d\)\= [jJ]\=\> ' display
328+ syn match pythonFloat ' \<\d\% ([_0-9]*\d\)\=\.\d\% ([_0-9]*\d\)\=\% ([eE][+-]\=\d\% ([_0-9]*\d\)\=\)\= [jJ]\= ' display
323329endif
324330
325331"
0 commit comments