@@ -53,6 +53,7 @@ if s:Enabled('g:python_highlight_all')
53
53
call s: EnableByDefault (' g:python_highlight_doctests' )
54
54
call s: EnableByDefault (' g:python_print_as_function' )
55
55
call s: EnableByDefault (' g:python_highlight_class_vars' )
56
+ call s: EnableByDefault (' g:python_highlight_operators' )
56
57
endif
57
58
58
59
"
73
74
syn keyword pythonRepeat for while
74
75
syn keyword pythonConditional if elif else
75
76
syn keyword pythonException try except finally
76
- syn keyword pythonOperator and in is not or
77
77
" The standard pyrex.vim unconditionally removes the pythonInclude group, so
78
78
" we provide a dummy group here to avoid crashing pyrex.vim.
79
79
syn keyword pythonInclude import
@@ -83,7 +83,6 @@ syn match pythonRaiseFromStatement '\<from\>'
83
83
syn match pythonImport ' ^\s *\z sfrom\> '
84
84
85
85
86
-
87
86
if s: Python2Syntax ()
88
87
if ! s: Enabled (' g:python_print_as_function' )
89
88
syn keyword pythonStatement print
100
99
syn cluster pythonExpression contains =pythonStatement,pythonRepeat,pythonConditional,pythonOperator,pythonNumber,pythonHexNumber,pythonOctNumber,pythonBinNumber,pythonFloat,pythonString,pythonBytes,pythonBoolean,pythonBuiltinObj,pythonBuiltinFunc
101
100
endif
102
101
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
+
103
112
"
104
113
" Decorators (new in Python 2.4)
105
114
"
@@ -127,10 +136,7 @@ syn keyword pythonTodo TODO FIXME XXX contained
127
136
" Errors
128
137
"
129
138
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
134
140
135
141
" Mixing spaces and tabs also may be used for pretty formatting multiline
136
142
" statements
@@ -275,34 +281,34 @@ endif
275
281
"
276
282
277
283
if 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
281
287
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
285
291
286
292
syn match pythonNumberError ' \<\d\+\D [lL]\=\> ' display
287
293
syn match pythonNumber ' \<\d [lL]\=\> ' display
288
294
syn match pythonNumber ' \< [0-9]\d\+ [lL]\=\> ' display
289
295
syn match pythonNumber ' \<\d\+ [lLjJ]\> ' display
290
296
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
293
299
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
297
303
else
298
- syn match pythonOctError ' \< 0[oO]\=\o *\D\+\d *\> ' display
304
+ syn match pythonOctError ' \< 0[oO]\=\o *\D\+\d *\> ' display
299
305
" 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
302
308
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
306
312
307
313
syn match pythonNumberError ' \<\d [_0-9]*\D\> ' display
308
314
syn match pythonNumberError ' \< 0[_0-9]\+\> ' display
@@ -314,12 +320,12 @@ else
314
320
syn match pythonNumber ' \<\d [jJ]\> ' display
315
321
syn match pythonNumber ' \< [1-9][_0-9]*\d [jJ]\> ' display
316
322
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
319
325
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
323
329
endif
324
330
325
331
"
0 commit comments