@@ -118,6 +118,12 @@ if exists("python_highlight_all") && python_highlight_all != 0
118
118
if ! exists (" python_highlight_doctests" )
119
119
let python_highlight_doctests = 1
120
120
endif
121
+ if ! exists (" python_highlight_keywords" )
122
+ let python_highlight_keywords = 1
123
+ endif
124
+ if ! exists (" python_highlight_operator" )
125
+ let python_highlight_operator = 1
126
+ endif
121
127
endif
122
128
123
129
" Keywords
@@ -148,30 +154,34 @@ syn region pythonFuncParams start="("ms=s+1 end=")"me=e-1 contained transparent
148
154
syn region pythonParam start =" [a-zA-Z_]" end =" \( ,\| )\s *:\) " contained contains =pythonParamName,pythonParamDefault,pythonDefaultAssignment transparent nextgroup =pythonParam
149
155
syn match pythonParamName " [a-zA-Z_][a-zA-Z0-9_]*" contained nextgroup =pythonDefaultAssignment skipwhite skipnl
150
156
syn match pythonDefaultAssignment " =" nextgroup =pythonParamDefault skipwhite contained skipnl
151
-
152
- syn region pythonFuncCall start =" [a-zA-Z_][a-zA-Z0-9_]*(" end =" )" contains =pythonFuncCallName,pythonFuncCallArgs
153
- syn match pythonFuncCallName " [a-zA-Z_][a-zA-Z0-9_]*" display contained nextgroup =pythonFuncCallArgs skipwhite
154
- syn region pythonFuncCallArgs start =" (" ms =s + 1 end =" )" me =e - 1 contained contains =pythonFuncCall,@pythonStringType,@pythonNumberType,@pythonBuiltin,pythonFuncCallKwargs
155
-
156
- syn match pythonFuncCallKwargs " [a-zA-Z_][a-zA-Z0-9_]*\s *=" display contained contains =pythonKey,pythonKeyAssign
157
- syn match pythonKey " [a-zA-Z_][a-zA-Z0-9_]*" display contained nextgroup =pythonKeyAssign skipwhite
158
- syn match pythonKeyAssign " =" display contained skipwhite
159
-
160
157
syn match pythonParamDefault " =\@ <=[^,]*" contained transparent contains =@pythonStringType,@pythonNumberType,@pythonBuiltin,pythonKeyword
161
158
162
- syn match pythonAssignment " +=\| -=\|\* =\| /=\| //=\| %=\| &=\| |=\|\^ =\| >>=\| <<=\|\*\* ="
163
- syn match pythonAssignment " ="
164
- syn match pythonArithmetic " +\| -\|\*\|\*\*\| /\| //\| %\| <<\| >>\| &\| |\|\^\|\~ "
165
- syn match pythonComparison " <\| >\| <=\| >=\| ==\| !=\| <>"
159
+ if exists (" python_highlight_operator" ) && python_highlight_operator != 0
160
+ syn match pythonAssignment " +=\| -=\|\* =\| /=\| //=\| %=\| &=\| |=\|\^ =\| >>=\| <<=\|\*\* ="
161
+ syn match pythonAssignment " ="
162
+ syn match pythonArithmetic " +\| -\|\*\|\*\*\| /\| //\| %\| <<\| >>\| &\| |\|\^\|\~ "
163
+ syn match pythonComparison " <\| >\| <=\| >=\| ==\| !=\| <>"
164
+ endif
166
165
167
166
if ! exists (" python_print_as_function" ) || python_print_as_function == 0
168
167
syn keyword pythonStatement print
169
168
endif
170
169
170
+ if exists (" python_highlight_keywords" ) && python_highlight_keywords != 0
171
+ syn region pythonCallName start =" [a-zA-Z_][a-zA-Z0-9_]*(" end =" )" fold contains =pythonCall keepend extend
172
+ syn region pythonCall start =" (" ms =s + 1 end =" )$" me =e - 1 contained contains =pythonCallArgs,@pythonExpression
173
+ syn match pythonCallArgs " [^,]" contained contains =pythonCallKeyword,pythonCallName,@pythonExpression skipwhite
174
+ syn match pythonCallKeyword " [a-zA-Z_][a-zA-Z0-9_]\+\s *=[^=]\{ 1\} " me =e - 1 display contained contains =pythonKeyAssign skipwhite
175
+ syn match pythonKeyAssign " =" display contained
176
+ endif
177
+
171
178
" Decorators (new in Python 2.4)
172
179
syn match pythonDecorator " @" display nextgroup =pythonDottedName skipwhite
173
- syn match pythonDottedName " [a-zA-Z_][a-zA-Z0-9_]*\(\. [a-zA-Z_][a-zA-Z0-9_]*\) *" display contained
180
+ syn match pythonDottedName " [a-zA-Z_][a-zA-Z0-9_]*\(\. [a-zA-Z_][a-zA-Z0-9_]*\) *" display contained nextgroup = pythonDecFac
174
181
syn match pythonDot " \. " display containedin =pythonDottedName
182
+ if exists (" python_highlight_keywords" ) && python_highlight_keywords != 0
183
+ syn region pythonDecFac start =" (" end =" )" contained contains =pythonCall keepend skipwhite
184
+ endif
175
185
176
186
" Comments
177
187
syn match pythonComment " #.*$" display contains =pythonTodo,@Spell
@@ -282,6 +292,7 @@ syn match pythonFloat "\<\d\+\.\d*\([eE][+-]\=\d\+\)\=[jJ]\=" display
282
292
syn match pythonOctError " \< 0[oO]\=\o *[8-9]\d *[lL]\=\> " display
283
293
syn match pythonBinError " \< 0[bB][01]*[2-9]\d *[lL]\=\> " display
284
294
295
+ syn cluster pythonExpression contains =pythonComparison,pythonOperator,pythonDot,@pythonStringType,@pythonNumberType,@pythonBuiltin,pythonFuncCall
285
296
syn cluster pythonStringType contains =pythonString,pythonUniString,pythonRawString,pythonUniRawString
286
297
syn cluster pythonNumberType contains =pythonNumber,pythonHexNumber,pythonFloat
287
298
syn cluster pythonBuiltin contains =pythonBuiltinObj,pythonBuiltinFunc
@@ -363,8 +374,11 @@ if version >= 508 || !exists("did_python_syn_inits")
363
374
HiLink pythonRepeat Repeat
364
375
HiLink pythonException Exception
365
376
HiLink pythonOperator Operator
377
+ HiLink pythonAssignment Operator
378
+ HiLink pythonArithmetic Operator
379
+ HiLink pythonComparison Operator
366
380
367
- HiLink pythonKey Identifier
381
+ HiLink pythonCallKeyword Identifier
368
382
HiLink pythonKeyAssign Operator
369
383
370
384
HiLink pythonFuncDef Special
@@ -378,7 +392,7 @@ if version >= 508 || !exists("did_python_syn_inits")
378
392
379
393
HiLink pythonDecorator Define
380
394
HiLink pythonDottedName Function
381
- HiLink pythonDot Normal
395
+ HiLink pythonDot Comment
382
396
383
397
HiLink pythonComment Comment
384
398
HiLink pythonCoding Special
0 commit comments