11" vim: ft = vim :fdm = marker
22
3- " Enable pymode syntax for python files
4- call pymode#default (' g:pymode' , 1 )
5- call pymode#default (' g:pymode_syntax' , g: pymode )
3+ " DESC: Check variable and set default value if it not exists
4+ fun ! s: Python3SyntaxDefault (name, default) " {{{
5+ if ! exists (a: name )
6+ let {a: name } = a: default
7+ return 0
8+ endif
9+ return 1
10+ endfunction " }}}
11+
12+ " Enable python3syntax for python files
13+ call s: Python3SyntaxDefault (' g:python3syntax' , 1 )
614
715" DESC: Disable script loading
8- if ! g: pymode || ! g: pymode_syntax || pymode#default ( ' b:current_syntax ' , ' pymode ' )
16+ if ! g: python3syntax
917 finish
1018endif
1119
1220" OPTIONS: {{{
1321
1422" Highlight all by default
15- call pymode#default (' g:pymode_syntax_all ' , 1 )
23+ call s: Python3SyntaxDefault (' g:python3syntax_all ' , 1 )
1624
1725" Highlight 'print' as function
18- call pymode#default (" g:pymode_syntax_print_as_function " , 0 )
26+ call s: Python3SyntaxDefault (" g:python3syntax_print_as_function " , 1 )
1927"
2028" Highlight 'async/await' keywords
21- call pymode#default (" g:pymode_syntax_highlight_async_await " , g: pymode_syntax_all )
29+ call s: Python3SyntaxDefault (" g:python3syntax_highlight_async_await " , g: python3syntax_all )
2230
2331" Highlight '=' operator
24- call pymode#default (' g:pymode_syntax_highlight_equal_operator ' , g: pymode_syntax_all )
32+ call s: Python3SyntaxDefault (' g:python3syntax_highlight_equal_operator ' , g: python3syntax_all )
2533
2634" Highlight '*' operator
27- call pymode#default (' g:pymode_syntax_highlight_stars_operator ' , g: pymode_syntax_all )
35+ call s: Python3SyntaxDefault (' g:python3syntax_highlight_stars_operator ' , g: python3syntax_all )
2836
2937" Highlight 'self' keyword
30- call pymode#default (' g:pymode_syntax_highlight_self ' , g: pymode_syntax_all )
38+ call s: Python3SyntaxDefault (' g:python3syntax_highlight_self ' , g: python3syntax_all )
3139
3240" Highlight indent's errors
33- call pymode#default (' g:pymode_syntax_indent_errors ' , g: pymode_syntax_all )
41+ call s: Python3SyntaxDefault (' g:python3syntax_indent_errors ' , g: python3syntax_all )
3442
3543" Highlight space's errors
36- call pymode#default (' g:pymode_syntax_space_errors ' , g: pymode_syntax_all )
44+ call s: Python3SyntaxDefault (' g:python3syntax_space_errors ' , g: python3syntax_all )
3745
3846" Highlight string formatting
39- call pymode#default (' g:pymode_syntax_string_formatting ' , g: pymode_syntax_all )
40- call pymode#default (' g:pymode_syntax_string_format ' , g: pymode_syntax_all )
41- call pymode#default (' g:pymode_syntax_string_templates ' , g: pymode_syntax_all )
42- call pymode#default (' g:pymode_syntax_doctests ' , g: pymode_syntax_all )
47+ call s: Python3SyntaxDefault (' g:python3syntax_string_formatting ' , g: python3syntax_all )
48+ call s: Python3SyntaxDefault (' g:python3syntax_string_format ' , g: python3syntax_all )
49+ call s: Python3SyntaxDefault (' g:python3syntax_string_templates ' , g: python3syntax_all )
50+ call s: Python3SyntaxDefault (' g:python3syntax_doctests ' , g: python3syntax_all )
4351
4452" Support docstrings in syntax highlighting
45- call pymode#default (' g:pymode_syntax_docstrings ' , 1 )
53+ call s: Python3SyntaxDefault (' g:python3syntax_docstrings ' , 1 )
4654
4755" Highlight builtin objects (True, False, ...)
48- call pymode#default (' g:pymode_syntax_builtin_objs ' , g: pymode_syntax_all )
56+ call s: Python3SyntaxDefault (' g:python3syntax_builtin_objs ' , g: python3syntax_all )
4957
5058" Highlight builtin types (str, list, ...)
51- call pymode#default (' g:pymode_syntax_builtin_types ' , g: pymode_syntax_all )
59+ call s: Python3SyntaxDefault (' g:python3syntax_builtin_types ' , g: python3syntax_all )
5260
5361" Highlight builtin types (div, eval, ...)
54- call pymode#default (' g:pymode_syntax_builtin_funcs ' , g: pymode_syntax_all )
62+ call s: Python3SyntaxDefault (' g:python3syntax_builtin_funcs ' , g: python3syntax_all )
5563
5664" Highlight exceptions (TypeError, ValueError, ...)
57- call pymode#default (' g:pymode_syntax_highlight_exceptions ' , g: pymode_syntax_all )
65+ call s: Python3SyntaxDefault (' g:python3syntax_highlight_exceptions ' , g: python3syntax_all )
5866
5967" More slow synchronizing. Disable on the slow machine, but code in docstrings
6068" could be broken.
61- call pymode#default (' g:pymode_syntax_slow_sync ' , 1 )
69+ call s: Python3SyntaxDefault (' g:python3syntax_slow_sync ' , 1 )
6270
6371" }}}
6472
@@ -100,26 +108,26 @@ endif
100108 syn match pythonExtraOperator " \% ([~!^&|/%+-]\|\% (class\s *\)\@ <!<<\| <=>\| <=\|\% (<\|\< class\s\+\u\w *\s *\)\@ <!<[^<]\@ =\| ===\| ==\| =\~\| >>\| >=\| =\@ <!>\|\.\.\.\|\.\.\| ::\) "
101109 syn match pythonExtraPseudoOperator " \% (-=\| /=\|\*\* =\|\* =\| &&=\| &=\| &&\| ||=\| |=\| ||\| %=\| +=\| !\~\| !=\) "
102110
103- if ! g: pymode_syntax_print_as_function
111+ if ! g: python3syntax_print_as_function
104112 syn keyword pythonStatement print
105113 endif
106114
107- if g: pymode_syntax_highlight_async_await
115+ if g: python3syntax_highlight_async_await
108116 syn keyword pythonStatement async await
109117 syn match pythonStatement " \< async\s\+ def\> " nextgroup =pythonFunction skipwhite
110118 syn match pythonStatement " \< async\s\+ with\> " display
111119 syn match pythonStatement " \< async\s\+ for\> " nextgroup =pythonRepeat skipwhite
112120 endif
113121
114- if g: pymode_syntax_highlight_equal_operator
122+ if g: python3syntax_highlight_equal_operator
115123 syn match pythonExtraOperator " \% (=\) "
116124 endif
117125
118- if g: pymode_syntax_highlight_stars_operator
126+ if g: python3syntax_highlight_stars_operator
119127 syn match pythonExtraOperator " \% (\*\|\*\*\) "
120128 endif
121129
122- if g: pymode_syntax_highlight_self
130+ if g: python3syntax_highlight_self
123131 syn keyword pythonSelf self cls
124132 endif
125133
@@ -156,12 +164,12 @@ endif
156164 syn match pythonError " [=]\{ 3,}" display
157165
158166 " Indent errors (mix space and tabs)
159- if g: pymode_syntax_indent_errors
167+ if g: python3syntax_indent_errors
160168 syn match pythonIndentError " ^\s *\( \t\|\t \)\s *\S " me =e - 1 display
161169 endif
162170
163171 " Trailing space errors
164- if g: pymode_syntax_space_errors
172+ if g: python3syntax_space_errors
165173 syn match pythonSpaceError " \s\+ $" display
166174 endif
167175
@@ -214,32 +222,32 @@ endif
214222 syn match pythonUniRawEscapeError " \( [^\\ ]\(\\\\\) *\)\@ <=\\ u\x\{ ,3}\X " display contained
215223
216224 " String formatting
217- if g: pymode_syntax_string_formatting
225+ if g: python3syntax_string_formatting
218226 syn match pythonStrFormatting " %\( ([^)]\+ )\)\= [-#0 +]*\d *\(\.\d\+\)\= [hlL]\= [diouxXeEfFgGcrs%]" contained containedin =pythonString,pythonUniString,pythonRawString,pythonUniRawString
219227 syn match pythonStrFormatting " %[-#0 +]*\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\= [hlL]\= [diouxXeEfFgGcrs%]" contained containedin =pythonString,pythonUniString,pythonRawString,pythonUniRawString
220228 endif
221229
222230 " Str.format syntax
223- if g: pymode_syntax_string_format
231+ if g: python3syntax_string_format
224232 syn match pythonStrFormat " {{\| }}" contained containedin =pythonString,pythonUniString,pythonRawString,pythonUniRawString
225233 syn match pythonStrFormat " {\( [a-zA-Z0-9_]*\|\d\+\)\(\. [a-zA-Z_][a-zA-Z0-9_]*\|\[\(\d\+\| [^!:\} ]\+\)\]\) *\( ![rs]\)\=\( :\( {\( [a-zA-Z_][a-zA-Z0-9_]*\|\d\+\) }\|\( [^}]\= [<>=^]\)\= [ +-]\= #\= 0\=\d *\(\.\d\+\)\= [bcdeEfFgGnoxX%]\=\)\=\)\= }" contained containedin =pythonString,pythonUniString,pythonRawString,pythonUniRawString
226234 endif
227235
228236 " String templates
229- if g: pymode_syntax_string_templates
237+ if g: python3syntax_string_templates
230238 syn match pythonStrTemplate " \$\$ " contained containedin =pythonString,pythonUniString,pythonRawString,pythonUniRawString
231239 syn match pythonStrTemplate " \$ {[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin =pythonString,pythonUniString,pythonRawString,pythonUniRawString
232240 syn match pythonStrTemplate " \$ [a-zA-Z_][a-zA-Z0-9_]*" contained containedin =pythonString,pythonUniString,pythonRawString,pythonUniRawString
233241 endif
234242
235243 " DocTests
236- if g: pymode_syntax_doctests
244+ if g: python3syntax_doctests
237245 syn region pythonDocTest start =" ^\s *>>>" end =+ '''+ he =s - 1 end =" ^\s *$" contained
238246 syn region pythonDocTest2 start =" ^\s *>>>" end =+ """+ he =s - 1 end =" ^\s *$" contained
239247 endif
240248
241249 " DocStrings
242- if g: pymode_syntax_docstrings
250+ if g: python3syntax_docstrings
243251 syn region pythonDocstring start =+ ^\s *[uU]\? [rR]\? """+ end =+ """+ keepend excludenl contains =pythonEscape,@Spell,pythonDoctest,pythonDocTest2,pythonSpaceError
244252 syn region pythonDocstring start =+ ^\s *[uU]\? [rR]\? '''+ end =+ '''+ keepend excludenl contains =pythonEscape,@Spell,pythonDoctest,pythonDocTest2,pythonSpaceError
245253 endif
@@ -267,20 +275,20 @@ endif
267275" ============
268276
269277 " Builtin objects and types
270- if g: pymode_syntax_builtin_objs
278+ if g: python3syntax_builtin_objs
271279 syn keyword pythonBuiltinObj True False Ellipsis None NotImplemented
272280 syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__
273281 endif
274282
275- if g: pymode_syntax_builtin_types
283+ if g: python3syntax_builtin_types
276284 syn keyword pythonBuiltinType type object
277285 syn keyword pythonBuiltinType str basestring unicode buffer bytearray bytes chr unichr
278286 syn keyword pythonBuiltinType dict int long bool float complex set frozenset list tuple
279287 syn keyword pythonBuiltinType file super
280288 endif
281289
282290 " Builtin functions
283- if g: pymode_syntax_builtin_funcs
291+ if g: python3syntax_builtin_funcs
284292 syn keyword pythonBuiltinFunc __import__ abs all any apply
285293 syn keyword pythonBuiltinFunc bin callable classmethod cmp coerce compile
286294 syn keyword pythonBuiltinFunc delattr dir divmod enumerate eval execfile filter
@@ -290,14 +298,14 @@ endif
290298 syn keyword pythonBuiltinFunc raw_input reduce reload repr reversed round setattr
291299 syn keyword pythonBuiltinFunc slice sorted staticmethod sum vars zip
292300
293- if g: pymode_syntax_print_as_function
301+ if g: python3syntax_print_as_function
294302 syn keyword pythonBuiltinFunc print
295303 endif
296304
297305 endif
298306
299307 " Builtin exceptions and warnings
300- if g: pymode_syntax_highlight_exceptions
308+ if g: python3syntax_highlight_exceptions
301309 syn keyword pythonExClass BaseException
302310 syn keyword pythonExClass Exception StandardError ArithmeticError
303311 syn keyword pythonExClass LookupError EnvironmentError
@@ -322,7 +330,7 @@ endif
322330" }}}
323331
324332
325- if g: pymode_syntax_slow_sync
333+ if g: python3syntax_slow_sync
326334 syn sync minlines =2000
327335else
328336 " This is fast but code inside triple quoted strings screws it up. It
0 commit comments