Browse Source

Merge f12e6e9bba6e2cb9d1d130c0d23007767478e69d into 453269d0f86ce3c2e401b1bc8f7dfc5e1b8a5b7d

Pedro Algarvio 10 years ago
parent
commit
624e0382ad
1 changed files with 343 additions and 492 deletions
  1. 343
    492
      syntax/python.vim

+ 343
- 492
syntax/python.vim View File

1
 " Vim syntax file
1
 " Vim syntax file
2
-" Language:     Python
3
-" Maintainer:   Dmitry Vasiliev <dima at hlabs dot org>
4
-" URL:          https://github.com/hdima/python-syntax
5
-" Last Change:  2013-11-18
6
-" Filenames:    *.py
7
-" Version:      3.3.6
8
-"
9
-" Based on python.vim (from Vim 6.1 distribution)
10
-" by Neil Schemenauer <nas at python dot ca>
11
-"
12
-" Please use the following channels for reporting bugs, offering suggestions or
13
-" feedback:
14
-
15
-" - python.vim issue tracker: https://github.com/hdima/python-syntax/issues
16
-" - Email: Dmitry Vasiliev (dima at hlabs.org)
17
-" - Send a message or follow me for updates on Twitter: `@hdima
18
-"   <https://twitter.com/hdima>`__
19
-"
20
-" Contributors
21
-" ============
22
-"
23
-" List of the contributors in alphabetical order:
24
-"
25
-"   Andrea Riciputi
26
-"   Anton Butanaev
27
-"   Caleb Adamantine
28
-"   Elizabeth Myers
29
-"   Jeroen Ruigrok van der Werven
30
-"   John Eikenberry
31
-"   Marc Weber
32
-"   Pedro Algarvio
33
-"   pydave at GitHub
34
-"   Will Gray
35
-"   Yuri Habrusiev
36
-"
37
-" Options
38
-" =======
39
-"
40
-"    :let OPTION_NAME = 1                   Enable option
41
-"    :let OPTION_NAME = 0                   Disable option
42
-"
43
-"
44
-" Option to select Python version
45
-" -------------------------------
46
-"
47
-"    python_version_2                       Enable highlighting for Python 2
48
-"                                           (Python 3 highlighting is enabled
49
-"                                           by default). Can also be set as
50
-"                                           a buffer (b:python_version_2)
51
-"                                           variable.
52
-"
53
-"    You can also use the following local to buffer commands to switch
54
-"    between two highlighting modes:
55
-"
56
-"    :Python2Syntax                         Switch to Python 2 highlighting
57
-"                                           mode
58
-"    :Python3Syntax                         Switch to Python 3 highlighting
59
-"                                           mode
60
-"
61
-" Option names used by the script
62
-" -------------------------------
63
-"
64
-"    python_highlight_builtins              Highlight builtin functions and
65
-"                                           objects
66
-"      python_highlight_builtin_objs        Highlight builtin objects only
67
-"      python_highlight_builtin_funcs       Highlight builtin functions only
68
-"    python_highlight_exceptions            Highlight standard exceptions
69
-"    python_highlight_string_formatting     Highlight % string formatting
70
-"    python_highlight_string_format         Highlight str.format syntax
71
-"    python_highlight_string_templates      Highlight string.Template syntax
72
-"    python_highlight_indent_errors         Highlight indentation errors
73
-"    python_highlight_space_errors          Highlight trailing spaces
74
-"    python_highlight_doctests              Highlight doc-tests
75
-"    python_print_as_function               Highlight 'print' statement as
76
-"                                           function for Python 2
77
-"    python_highlight_file_headers_as_comments
78
-"                                           Highlight shebang and coding
79
-"                                           headers as comments
80
-"
81
-"    python_highlight_all                   Enable all the options above
82
-"                                           NOTE: This option don't override
83
-"                                           any previously set options
84
-"
85
-"    python_slow_sync                       Can be set to 0 for slow machines
86
-"
87
-
88
-" For version 5.x: Clear all syntax items
89
-" For versions greater than 6.x: Quit when a syntax file was already loaded
2
+" Language:	Python
3
+" Maintainer:	Neil Schemenauer <nas@python.ca>
4
+" Last Change:	2014 Jul 16
5
+" Credits:	Zvezdan Petkovic <zpetkovic@acm.org>
6
+"		Neil Schemenauer <nas@python.ca>
7
+"		Dmitry Vasiliev
8
+"
9
+"		This version is a major rewrite by Zvezdan Petkovic.
10
+"
11
+"		- introduced highlighting of doctests
12
+"		- updated keywords, built-ins, and exceptions
13
+"		- corrected regular expressions for
14
+"
15
+"		  * functions
16
+"		  * decorators
17
+"		  * strings
18
+"		  * escapes
19
+"		  * numbers
20
+"		  * space error
21
+"
22
+"		- corrected synchronization
23
+"		- more highlighting is ON by default, except
24
+"		- space error highlighting is OFF by default
25
+"
26
+" Optional highlighting can be controlled using these variables.
27
+"
28
+"   let python_no_builtin_highlight = 1
29
+"   let python_no_self_highlight = 1
30
+"   let python_no_doctest_code_highlight = 1
31
+"   let python_no_doctest_highlight = 1
32
+"   let python_no_exception_highlight = 1
33
+"   let python_no_number_highlight = 1
34
+"   let python_no_string_format_highlight = 1
35
+"   let python_no_string_formatting_highlight = 1
36
+"   let python_no_string_template_highlight = 1
37
+"   let python_no_extra_operators_highlight = 1
38
+"   let python_no_stars_operators_highlight = 1
39
+"   let python_no_equal_sign_operator_highlight = 1
40
+"   let python_space_error_highlight = 1
41
+"   let python_shebang_header_highlight = 1
42
+"   let python_coding_header_highlight = 1
43
+"
44
+" All the options above can be switched on together.
45
+"
46
+"   let python_highlight_all = 1
47
+"
48
+
49
+" For version 5.x: Clear all syntax items.
50
+" For version 6.x: Quit when a syntax file was already loaded.
90
 if version < 600
51
 if version < 600
91
   syntax clear
52
   syntax clear
92
 elseif exists("b:current_syntax")
53
 elseif exists("b:current_syntax")
93
   finish
54
   finish
94
 endif
55
 endif
95
 
56
 
96
-"
97
-" Commands
98
-"
99
-command! -buffer Python2Syntax let b:python_version_2 = 1 | let &syntax=&syntax
100
-command! -buffer Python3Syntax let b:python_version_2 = 0 | let &syntax=&syntax
57
+" We need nocompatible mode in order to continue lines with backslashes.
58
+" Original setting will be restored.
59
+let s:cpo_save = &cpo
60
+set cpo&vim
101
 
61
 
102
-" Enable option if it's not defined
103
-function! s:EnableByDefault(name)
104
-  if !exists(a:name)
105
-    let {a:name} = 1
62
+if exists("python_highlight_all")
63
+  if exists("python_no_builtin_highlight")
64
+    unlet python_no_builtin_highlight
106
   endif
65
   endif
107
-endfunction
108
-
109
-" Check if option is enabled
110
-function! s:Enabled(name)
111
-  return exists(a:name) && {a:name}
112
-endfunction
113
-
114
-" Is it Python 2 syntax?
115
-function! s:Python2Syntax()
116
-  if exists("b:python_version_2")
117
-      return b:python_version_2
66
+  if exists("python_no_self_highlight")
67
+    unlet python_no_self_highlight
118
   endif
68
   endif
119
-  return s:Enabled("g:python_version_2")
120
-endfunction
121
-
122
-"
123
-" Default options
124
-"
125
-
126
-call s:EnableByDefault("g:python_slow_sync")
127
-
128
-if s:Enabled("g:python_highlight_all")
129
-  call s:EnableByDefault("g:python_highlight_builtins")
130
-  if s:Enabled("g:python_highlight_builtins")
131
-    call s:EnableByDefault("g:python_highlight_builtin_objs")
132
-    call s:EnableByDefault("g:python_highlight_builtin_funcs")
69
+  if exists("python_no_doctest_code_highlight")
70
+    unlet python_no_doctest_code_highlight
133
   endif
71
   endif
134
-  call s:EnableByDefault("g:python_highlight_exceptions")
135
-  call s:EnableByDefault("g:python_highlight_string_formatting")
136
-  call s:EnableByDefault("g:python_highlight_string_format")
137
-  call s:EnableByDefault("g:python_highlight_string_templates")
138
-  call s:EnableByDefault("g:python_highlight_indent_errors")
139
-  call s:EnableByDefault("g:python_highlight_space_errors")
140
-  call s:EnableByDefault("g:python_highlight_doctests")
141
-  call s:EnableByDefault("g:python_print_as_function")
142
-endif
143
-
144
-"
145
-" Keywords
146
-"
147
-
148
-syn keyword pythonStatement     break continue del
149
-syn keyword pythonStatement     exec return
150
-syn keyword pythonStatement     pass raise
151
-syn keyword pythonStatement     global assert
152
-syn keyword pythonStatement     lambda
153
-syn keyword pythonStatement     with
154
-syn keyword pythonStatement     def class nextgroup=pythonFunction skipwhite
155
-syn keyword pythonRepeat        for while
156
-syn keyword pythonConditional   if elif else
157
-syn keyword pythonImport        import
158
-syn keyword pythonException     try except finally
159
-syn keyword pythonOperator      and in is not or
160
-
161
-syn match pythonStatement   "\<yield\>" display
162
-syn match pythonImport      "\<from\>" display
163
-
164
-if s:Python2Syntax()
165
-  if !s:Enabled("g:python_print_as_function")
166
-    syn keyword pythonStatement  print
72
+  if exists("python_no_doctest_highlight")
73
+    unlet python_no_doctest_highlight
167
   endif
74
   endif
168
-  syn keyword pythonImport      as
169
-  syn match   pythonFunction    "[a-zA-Z_][a-zA-Z0-9_]*" display contained
170
-else
171
-  syn keyword pythonStatement   as nonlocal None
172
-  syn match   pythonStatement   "\<yield\s\+from\>" display
173
-  syn keyword pythonBoolean     True False
174
-  syn match   pythonFunction    "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
175
-endif
176
-
177
-"
178
-" Decorators (new in Python 2.4)
179
-"
180
-
181
-syn match   pythonDecorator	"@" display nextgroup=pythonDottedName skipwhite
182
-syn match   pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display contained
183
-syn match   pythonDot        "\." display containedin=pythonDottedName
184
-
185
-"
186
-" Comments
187
-"
188
-
189
-syn match   pythonComment	"#.*$" display contains=pythonTodo,@Spell
190
-if !s:Enabled("g:python_highlight_file_headers_as_comments")
191
-  syn match   pythonRun		"\%^#!.*$"
192
-  syn match   pythonCoding	"\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"
75
+  if exists("python_no_exception_highlight")
76
+    unlet python_no_exception_highlight
77
+  endif
78
+  if exists("python_no_number_highlight")
79
+    unlet python_no_number_highlight
80
+  endif
81
+  if exists("python_no_string_format_highlight")
82
+    unlet python_no_string_format_highlight
83
+  endif
84
+  if exists("python_no_string_formatting_highlight")
85
+    unlet python_no_string_formatting_highlight
86
+  endif
87
+  if exists("python_no_string_template_highlight")
88
+    unlet python_no_string_template_highlight
89
+  endif
90
+  if exists("python_no_extra_operators_highlight")
91
+    unlet python_no_extra_operators_highlight
92
+  endif
93
+  if exists("python_no_stars_operators_highlight")
94
+    unlet python_no_stars_operators_highlight
95
+  endif
96
+  if exists("python_no_equal_sign_operator_highlight")
97
+    unlet python_no_equal_sign_operator_highlight
98
+  endif
99
+  let python_space_error_highlight = 1
100
+  let python_shebang_header_highlight = 1
101
+  let python_coding_header_highlight = 1
193
 endif
102
 endif
194
-syn keyword pythonTodo		TODO FIXME XXX contained
195
 
103
 
196
-"
197
-" Errors
198
-"
199
-
200
-syn match pythonError		"\<\d\+\D\+\>" display
201
-syn match pythonError		"[$?]" display
202
-syn match pythonError		"[&|]\{2,}" display
203
-syn match pythonError		"[=]\{3,}" display
204
-
205
-" Mixing spaces and tabs also may be used for pretty formatting multiline
206
-" statements
207
-if s:Enabled("g:python_highlight_indent_errors")
208
-  syn match pythonIndentError	"^\s*\%( \t\|\t \)\s*\S"me=e-1 display
104
+" Keep Python keywords in alphabetical order inside groups for easy
105
+" comparison with the table in the 'Python Language Reference'
106
+" http://docs.python.org/reference/lexical_analysis.html#keywords.
107
+" Groups are in the order presented in NAMING CONVENTIONS in syntax.txt.
108
+" Exceptions come last at the end of each group (class and def below).
109
+"
110
+" Keywords 'with' and 'as' are new in Python 2.6
111
+" (use 'from __future__ import with_statement' in Python 2.5).
112
+"
113
+" Some compromises had to be made to support both Python 3.0 and 2.6.
114
+" We include Python 3.0 features, but when a definition is duplicated,
115
+" the last definition takes precedence.
116
+"
117
+" - 'False', 'None', and 'True' are keywords in Python 3.0 but they are
118
+"   built-ins in 2.6 and will be highlighted as built-ins below.
119
+" - 'exec' is a built-in in Python 3.0 and will be highlighted as
120
+"   built-in below.
121
+" - 'nonlocal' is a keyword in Python 3.0 and will be highlighted.
122
+" - 'print' is a built-in in Python 3.0 and will be highlighted as
123
+"   built-in below (use 'from __future__ import print_function' in 2.6)
124
+"
125
+syn keyword pythonStatement	False, None, True
126
+syn keyword pythonStatement	as assert break continue del exec global
127
+syn keyword pythonStatement	lambda nonlocal pass print return with yield
128
+syn keyword pythonStatement	class def nextgroup=pythonFunction skipwhite
129
+syn keyword pythonConditional	elif else if
130
+syn keyword pythonRepeat	for while
131
+syn keyword pythonOperator	and in is not or
132
+syn keyword pythonException	except finally raise try
133
+syn keyword pythonInclude	from import
134
+if !exists("python_no_self_highlight")
135
+  syn keyword pythonSelf	self cls
209
 endif
136
 endif
210
 
137
 
211
-" Trailing space errors
212
-if s:Enabled("g:python_highlight_space_errors")
213
-  syn match pythonSpaceError	"\s\+$" display
138
+if !exists("python_no_extra_operators_highlight")
139
+  syn match pythonExtraOperator "\%([~!^&|/%+-]\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|=\@<!>\|\.\.\.\|\.\.\|::\)"
140
+  syn match pythonExtraPseudoOperator "\%(-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!=\)"
214
 endif
141
 endif
215
 
142
 
216
-"
217
-" Strings
218
-"
219
-
220
-if s:Python2Syntax()
221
-  " Python 2 strings
222
-  syn region pythonString   start=+[bB]\='+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
223
-  syn region pythonString   start=+[bB]\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
224
-  syn region pythonString   start=+[bB]\="""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
225
-  syn region pythonString   start=+[bB]\='''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
226
-else
227
-  " Python 3 byte strings
228
-  syn region pythonBytes		start=+[bB]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell
229
-  syn region pythonBytes		start=+[bB]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell
230
-  syn region pythonBytes		start=+[bB]"""+ end=+"""+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest2,pythonSpaceError,@Spell
231
-  syn region pythonBytes		start=+[bB]'''+ end=+'''+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest,pythonSpaceError,@Spell
232
-
233
-  syn match pythonBytesError    ".\+" display contained
234
-  syn match pythonBytesContent  "[\u0000-\u00ff]\+" display contained contains=pythonBytesEscape,pythonBytesEscapeError
143
+if !exists("python_no_stars_operators_highlight")
144
+  syn match pythonExtraOperator "\%(\*\|\*\*\)"
235
 endif
145
 endif
236
 
146
 
237
-syn match pythonBytesEscape       +\\[abfnrtv'"\\]+ display contained
238
-syn match pythonBytesEscape       "\\\o\o\=\o\=" display contained
239
-syn match pythonBytesEscapeError  "\\\o\{,2}[89]" display contained
240
-syn match pythonBytesEscape       "\\x\x\{2}" display contained
241
-syn match pythonBytesEscapeError  "\\x\x\=\X" display contained
242
-syn match pythonBytesEscape       "\\$"
243
-
244
-syn match pythonUniEscape         "\\u\x\{4}" display contained
245
-syn match pythonUniEscapeError    "\\u\x\{,3}\X" display contained
246
-syn match pythonUniEscape         "\\U\x\{8}" display contained
247
-syn match pythonUniEscapeError    "\\U\x\{,7}\X" display contained
248
-syn match pythonUniEscape         "\\N{[A-Z ]\+}" display contained
249
-syn match pythonUniEscapeError    "\\N{[^A-Z ]\+}" display contained
250
-
251
-if s:Python2Syntax()
252
-  " Python 2 Unicode strings
253
-  syn region pythonUniString  start=+[uU]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
254
-  syn region pythonUniString  start=+[uU]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
255
-  syn region pythonUniString  start=+[uU]"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
256
-  syn region pythonUniString  start=+[uU]'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
257
-else
258
-  " Python 3 strings
259
-  syn region pythonString   start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
260
-  syn region pythonString   start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
261
-  syn region pythonString   start=+"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
262
-  syn region pythonString   start=+'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
147
+if !exists("python_no_equal_sign_operator_highlight")
148
+  syn match pythonExtraOperator "\%(=\)"
263
 endif
149
 endif
264
 
150
 
265
-if s:Python2Syntax()
266
-  " Python 2 Unicode raw strings
267
-  syn region pythonUniRawString start=+[uU][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell
268
-  syn region pythonUniRawString start=+[uU][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell
269
-  syn region pythonUniRawString start=+[uU][rR]"""+ end=+"""+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest2,pythonSpaceError,@Spell
270
-  syn region pythonUniRawString start=+[uU][rR]'''+ end=+'''+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest,pythonSpaceError,@Spell
271
-
272
-  syn match  pythonUniRawEscape       "\([^\\]\(\\\\\)*\)\@<=\\u\x\{4}" display contained
273
-  syn match  pythonUniRawEscapeError  "\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display contained
151
+" Decorators (new in Python 2.4)
152
+syn match   pythonDecorator	"@" display nextgroup=pythonFunction skipwhite
153
+" The zero-length non-grouping match before the function name is
154
+" extremely important in pythonFunction.  Without it, everything is
155
+" interpreted as a function inside the contained environment of
156
+" doctests.
157
+" A dot must be allowed because of @MyClass.myfunc decorators.
158
+syn match   pythonFunction
159
+      \ "\%(\%(def\s\|class\s\|@\)\s*\)\@<=\h\%(\w\|\.\)*" contained
160
+
161
+" Add spelling to comments with some exceptions
162
+syn match   pythonComment	"#.*$" contains=pythonTodo,@Spell
163
+" Skip for PyLint's in-line comment rules
164
+syn match   pythonComment	"# pylint:.*$" contains=@NoSpell
165
+" Skip noqa inline comments
166
+syn match   pythonComment	"# noqa.*$" contains=@NoSpell
167
+syn keyword pythonTodo		FIXME NOTE NOTES TODO XXX contained
168
+
169
+" Triple-quoted strings can contain doctests.
170
+syn region  pythonString
171
+      \ start=+[uU]\=\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1"
172
+      \ contains=pythonEscape,@Spell
173
+syn region  pythonString
174
+      \ start=+[uU]\=\z('''\|"""\)+ end="\z1" keepend
175
+      \ contains=pythonEscape,pythonSpaceError,pythonDoctest,@Spell
176
+syn region  pythonRawString
177
+      \ start=+[uU]\=[rR]\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1"
178
+      \ contains=@Spell
179
+syn region  pythonRawString
180
+      \ start=+[uU]\=[rR]\z('''\|"""\)+ end="\z1" keepend
181
+      \ contains=pythonSpaceError,pythonDoctest,@Spell
182
+
183
+syn match   pythonEscape	+\\[abfnrtv'"\\]+ contained
184
+syn match   pythonEscape	"\\\o\{1,3}" contained
185
+syn match   pythonEscape	"\\x\x\{2}" contained
186
+syn match   pythonEscape	"\%(\\u\x\{4}\|\\U\x\{8}\)" contained
187
+" Python allows case-insensitive Unicode IDs: http://www.unicode.org/charts/
188
+syn match   pythonEscape	"\\N{.\{-}}" contained
189
+syn match   pythonEscape	"\\$"
190
+
191
+
192
+if !exists("python_no_string_format_highlight")
193
+  syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString
194
+  syn match pythonStrFormat "{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonRawString
274
 endif
195
 endif
275
 
196
 
276
-" Python 2/3 raw strings
277
-if s:Python2Syntax()
278
-  syn region pythonRawString  start=+[bB]\=[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell
279
-  syn region pythonRawString  start=+[bB]\=[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell
280
-  syn region pythonRawString  start=+[bB]\=[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell
281
-  syn region pythonRawString  start=+[bB]\=[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell
282
-else
283
-  syn region pythonRawString  start=+[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell
284
-  syn region pythonRawString  start=+[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell
285
-  syn region pythonRawString  start=+[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell
286
-  syn region pythonRawString  start=+[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell
287
-
288
-  syn region pythonRawBytes  start=+[bB][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell
289
-  syn region pythonRawBytes  start=+[bB][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell
290
-  syn region pythonRawBytes  start=+[bB][rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell
291
-  syn region pythonRawBytes  start=+[bB][rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell
197
+if !exists("python_no_string_formatting_highlight")
198
+  syn match pythonStrFormatting "%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonRawString
199
+  syn match pythonStrFormatting "%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonRawString
292
 endif
200
 endif
293
 
201
 
294
-syn match pythonRawEscape +\\['"]+ display transparent contained
295
-
296
-if s:Enabled("g:python_highlight_string_formatting")
297
-  " % operator string formatting
298
-  if s:Python2Syntax()
299
-    syn match pythonStrFormatting	"%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString
300
-    syn match pythonStrFormatting	"%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString
301
-  else
302
-    syn match pythonStrFormatting	"%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonRawString
303
-    syn match pythonStrFormatting	"%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonRawString
304
-  endif
202
+if !exists("python_no_string_template_highlight")
203
+  syn match pythonStrTemplate "\$\$" contained containedin=pythonString,pythonRawString
204
+  syn match pythonStrTemplate "\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonRawString
205
+  syn match pythonStrTemplate "\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonRawString
305
 endif
206
 endif
306
 
207
 
307
-if s:Enabled("g:python_highlight_string_format")
308
-  " str.format syntax
309
-  if s:Python2Syntax()
310
-    syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString
311
-    syn match pythonStrFormat	"{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString
312
-  else
313
-    syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString
314
-    syn match pythonStrFormat	"{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonRawString
315
-  endif
208
+" It is very important to understand all details before changing the
209
+" regular expressions below or their order.
210
+" The word boundaries are *not* the floating-point number boundaries
211
+" because of a possible leading or trailing decimal point.
212
+" The expressions below ensure that all valid number literals are
213
+" highlighted, and invalid number literals are not.  For example,
214
+"
215
+" - a decimal point in '4.' at the end of a line is highlighted,
216
+" - a second dot in 1.0.0 is not highlighted,
217
+" - 08 is not highlighted,
218
+" - 08e0 or 08j are highlighted,
219
+"
220
+" and so on, as specified in the 'Python Language Reference'.
221
+" http://docs.python.org/reference/lexical_analysis.html#numeric-literals
222
+if !exists("python_no_number_highlight")
223
+  " numbers (including longs and complex)
224
+  syn match   pythonNumber	"\<0[oO]\=\o\+[Ll]\=\>"
225
+  syn match   pythonNumber	"\<0[xX]\x\+[Ll]\=\>"
226
+  syn match   pythonNumber	"\<0[bB][01]\+[Ll]\=\>"
227
+  syn match   pythonNumber	"\<\%([1-9]\d*\|0\)[Ll]\=\>"
228
+  syn match   pythonNumber	"\<\d\+[jJ]\>"
229
+  syn match   pythonNumber	"\<\d\+[eE][+-]\=\d\+[jJ]\=\>"
230
+  syn match   pythonNumber
231
+	\ "\<\d\+\.\%([eE][+-]\=\d\+\)\=[jJ]\=\%(\W\|$\)\@="
232
+  syn match   pythonNumber
233
+	\ "\%(^\|\W\)\@<=\d*\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>"
316
 endif
234
 endif
317
 
235
 
318
-if s:Enabled("g:python_highlight_string_templates")
319
-  " string.Template format
320
-  if s:Python2Syntax()
321
-    syn match pythonStrTemplate	"\$\$" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString
322
-    syn match pythonStrTemplate	"\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString
323
-    syn match pythonStrTemplate	"\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString
324
-  else
325
-    syn match pythonStrTemplate	"\$\$" contained containedin=pythonString,pythonRawString
326
-    syn match pythonStrTemplate	"\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonRawString
327
-    syn match pythonStrTemplate	"\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonRawString
328
-  endif
236
+" Group the built-ins in the order in the 'Python Library Reference' for
237
+" easier comparison.
238
+" http://docs.python.org/library/constants.html
239
+" http://docs.python.org/library/functions.html
240
+" http://docs.python.org/library/functions.html#non-essential-built-in-functions
241
+" Python built-in functions are in alphabetical order.
242
+if !exists("python_no_builtin_highlight")
243
+  " built-in constants
244
+  " 'False', 'True', and 'None' are also reserved words in Python 3.0
245
+  syn keyword pythonBuiltin	False True None
246
+  syn keyword pythonBuiltin	NotImplemented Ellipsis __debug__
247
+  " built-in functions
248
+  syn keyword pythonBuiltin	abs all any bin bool chr classmethod
249
+  syn keyword pythonBuiltin	compile complex delattr dict dir divmod
250
+  syn keyword pythonBuiltin	enumerate eval filter float format
251
+  syn keyword pythonBuiltin	frozenset getattr globals hasattr hash
252
+  syn keyword pythonBuiltin	help hex id input int isinstance
253
+  syn keyword pythonBuiltin	issubclass iter len list locals map max
254
+  syn keyword pythonBuiltin	min next object oct open ord pow print
255
+  syn keyword pythonBuiltin	property range repr reversed round set
256
+  syn keyword pythonBuiltin	setattr slice sorted staticmethod str
257
+  syn keyword pythonBuiltin	sum super tuple type vars zip __import__
258
+  " Python 2.6 only
259
+  syn keyword pythonBuiltin	basestring callable cmp execfile file
260
+  syn keyword pythonBuiltin	long raw_input reduce reload unichr
261
+  syn keyword pythonBuiltin	unicode xrange
262
+  " Python 3.0 only
263
+  syn keyword pythonBuiltin	ascii bytearray bytes exec memoryview
264
+  " non-essential built-in functions; Python 2.6 only
265
+  syn keyword pythonBuiltin	apply buffer coerce intern
329
 endif
266
 endif
330
 
267
 
331
-if s:Enabled("g:python_highlight_doctests")
332
-  " DocTests
333
-  syn region pythonDocTest	start="^\s*>>>" end=+'''+he=s-1 end="^\s*$" contained
334
-  syn region pythonDocTest2	start="^\s*>>>" end=+"""+he=s-1 end="^\s*$" contained
268
+" From the 'Python Library Reference' class hierarchy at the bottom.
269
+" http://docs.python.org/library/exceptions.html
270
+if !exists("python_no_exception_highlight")
271
+  " builtin base exceptions (only used as base classes for other exceptions)
272
+  syn keyword pythonExceptions	BaseException Exception
273
+  syn keyword pythonExceptions	ArithmeticError EnvironmentError
274
+  syn keyword pythonExceptions	LookupError
275
+  " builtin base exception removed in Python 3.0
276
+  syn keyword pythonExceptions	StandardError
277
+  " builtin exceptions (actually raised)
278
+  syn keyword pythonExceptions	AssertionError AttributeError BufferError
279
+  syn keyword pythonExceptions	EOFError FloatingPointError GeneratorExit
280
+  syn keyword pythonExceptions	IOError ImportError IndentationError
281
+  syn keyword pythonExceptions	IndexError KeyError KeyboardInterrupt
282
+  syn keyword pythonExceptions	MemoryError NameError NotImplementedError
283
+  syn keyword pythonExceptions	OSError OverflowError ReferenceError
284
+  syn keyword pythonExceptions	RuntimeError StopIteration SyntaxError
285
+  syn keyword pythonExceptions	SystemError SystemExit TabError TypeError
286
+  syn keyword pythonExceptions	UnboundLocalError UnicodeError
287
+  syn keyword pythonExceptions	UnicodeDecodeError UnicodeEncodeError
288
+  syn keyword pythonExceptions	UnicodeTranslateError ValueError VMSError
289
+  syn keyword pythonExceptions	WindowsError ZeroDivisionError
290
+  " builtin warnings
291
+  syn keyword pythonExceptions	BytesWarning DeprecationWarning FutureWarning
292
+  syn keyword pythonExceptions	ImportWarning PendingDeprecationWarning
293
+  syn keyword pythonExceptions	RuntimeWarning SyntaxWarning UnicodeWarning
294
+  syn keyword pythonExceptions	UserWarning Warning
335
 endif
295
 endif
336
 
296
 
337
-"
338
-" Numbers (ints, longs, floats, complex)
339
-"
340
-
341
-if s:Python2Syntax()
342
-  syn match   pythonHexError	"\<0[xX]\x*[g-zG-Z]\+\x*[lL]\=\>" display
343
-  syn match   pythonOctError	"\<0[oO]\=\o*\D\+\d*[lL]\=\>" display
344
-  syn match   pythonBinError	"\<0[bB][01]*\D\+\d*[lL]\=\>" display
345
-
346
-  syn match   pythonHexNumber	"\<0[xX]\x\+[lL]\=\>" display
347
-  syn match   pythonOctNumber "\<0[oO]\o\+[lL]\=\>" display
348
-  syn match   pythonBinNumber "\<0[bB][01]\+[lL]\=\>" display
349
-
350
-  syn match   pythonNumberError	"\<\d\+\D[lL]\=\>" display
351
-  syn match   pythonNumber	"\<\d[lL]\=\>" display
352
-  syn match   pythonNumber	"\<[0-9]\d\+[lL]\=\>" display
353
-  syn match   pythonNumber	"\<\d\+[lLjJ]\>" display
354
-
355
-  syn match   pythonOctError	"\<0[oO]\=\o*[8-9]\d*[lL]\=\>" display
356
-  syn match   pythonBinError	"\<0[bB][01]*[2-9]\d*[lL]\=\>" display
357
-else
358
-  syn match   pythonHexError	"\<0[xX]\x*[g-zG-Z]\x*\>" display
359
-  syn match   pythonOctError	"\<0[oO]\=\o*\D\+\d*\>" display
360
-  syn match   pythonBinError	"\<0[bB][01]*\D\+\d*\>" display
361
-
362
-  syn match   pythonHexNumber	"\<0[xX]\x\+\>" display
363
-  syn match   pythonOctNumber "\<0[oO]\o\+\>" display
364
-  syn match   pythonBinNumber "\<0[bB][01]\+\>" display
365
-
366
-  syn match   pythonNumberError	"\<\d\+\D\>" display
367
-  syn match   pythonNumberError	"\<0\d\+\>" display
368
-  syn match   pythonNumber	"\<\d\>" display
369
-  syn match   pythonNumber	"\<[1-9]\d\+\>" display
370
-  syn match   pythonNumber	"\<\d\+[jJ]\>" display
371
-
372
-  syn match   pythonOctError	"\<0[oO]\=\o*[8-9]\d*\>" display
373
-  syn match   pythonBinError	"\<0[bB][01]*[2-9]\d*\>" display
297
+if exists("python_space_error_highlight")
298
+  " trailing whitespace
299
+  syn match   pythonSpaceError	display excludenl "\s\+$"
300
+  " mixed tabs and spaces
301
+  syn match   pythonSpaceError	display " \+\t"
302
+  syn match   pythonSpaceError	display "\t\+ "
374
 endif
303
 endif
375
 
304
 
376
-syn match   pythonFloat		"\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>" display
377
-syn match   pythonFloat		"\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display
378
-syn match   pythonFloat		"\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=" display
379
-
380
-"
381
-" Builtin objects and types
382
-"
383
-
384
-if s:Enabled("g:python_highlight_builtin_objs")
385
-  if s:Python2Syntax()
386
-    syn keyword pythonBuiltinObj	None
387
-    syn keyword pythonBoolean		True False
388
-  endif
389
-  syn keyword pythonBuiltinObj	Ellipsis NotImplemented
390
-  syn keyword pythonBuiltinObj	__debug__ __doc__ __file__ __name__ __package__
305
+if exists("python_shebang_header_highlight")
306
+  syn match pythonRun "\%^#!.*$" contains=@NoSpell
391
 endif
307
 endif
392
 
308
 
393
-"
394
-" Builtin functions
395
-"
396
-
397
-if s:Enabled("g:python_highlight_builtin_funcs")
398
-  if s:Python2Syntax()
399
-    syn keyword pythonBuiltinFunc	apply basestring buffer callable coerce
400
-    syn keyword pythonBuiltinFunc	execfile file help intern long raw_input
401
-    syn keyword pythonBuiltinFunc	reduce reload unichr unicode xrange
402
-    if s:Enabled("g:python_print_as_function")
403
-      syn keyword pythonBuiltinFunc	print
404
-    endif
405
-  else
406
-    syn keyword pythonBuiltinFunc	ascii exec memoryview print
407
-  endif
408
-  syn keyword pythonBuiltinFunc	__import__ abs all any
409
-  syn keyword pythonBuiltinFunc	bin bool bytearray bytes
410
-  syn keyword pythonBuiltinFunc	chr classmethod cmp compile complex
411
-  syn keyword pythonBuiltinFunc	delattr dict dir divmod enumerate eval
412
-  syn keyword pythonBuiltinFunc	filter float format frozenset getattr
413
-  syn keyword pythonBuiltinFunc	globals hasattr hash hex id
414
-  syn keyword pythonBuiltinFunc	input int isinstance
415
-  syn keyword pythonBuiltinFunc	issubclass iter len list locals map max
416
-  syn keyword pythonBuiltinFunc	min next object oct open ord
417
-  syn keyword pythonBuiltinFunc	pow property range
418
-  syn keyword pythonBuiltinFunc	repr reversed round set setattr
419
-  syn keyword pythonBuiltinFunc	slice sorted staticmethod str sum super tuple
420
-  syn keyword pythonBuiltinFunc	type vars zip
309
+if exists("python_coding_header_highlight")
310
+  syn match pythonCoding "\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$" contains=@NoSpell
421
 endif
311
 endif
422
 
312
 
423
-"
424
-" Builtin exceptions and warnings
425
-"
426
-
427
-if s:Enabled("g:python_highlight_exceptions")
428
-  if s:Python2Syntax()
429
-    syn keyword pythonExClass	StandardError
313
+" Do not spell doctests inside strings.
314
+" Notice that the end of a string, either ''', or """, will end the contained
315
+" doctest too.  Thus, we do *not* need to have it as an end pattern.
316
+if !exists("python_no_doctest_highlight")
317
+  if !exists("python_no_doctest_code_highlight")
318
+    syn region pythonDoctest
319
+	  \ start="^\s*>>>\s" end="^\s*$"
320
+	  \ contained contains=ALLBUT,pythonDoctest,@Spell
321
+    syn region pythonDoctestValue
322
+	  \ start=+^\s*\%(>>>\s\|\.\.\.\s\|"""\|'''\)\@!\S\++ end="$"
323
+	  \ contained
430
   else
324
   else
431
-    syn keyword pythonExClass	BlockingIOError ChildProcessError
432
-    syn keyword pythonExClass	ConnectionError BrokenPipeError
433
-    syn keyword pythonExClass	ConnectionAbortedError ConnectionRefusedError
434
-    syn keyword pythonExClass	ConnectionResetError FileExistsError
435
-    syn keyword pythonExClass	FileNotFoundError InterruptedError
436
-    syn keyword pythonExClass	IsADirectoryError NotADirectoryError
437
-    syn keyword pythonExClass	PermissionError ProcessLookupError TimeoutError
438
-
439
-    syn keyword pythonExClass	ResourceWarning
325
+    syn region pythonDoctest
326
+	  \ start="^\s*>>>" end="^\s*$"
327
+	  \ contained contains=@NoSpell
440
   endif
328
   endif
441
-  syn keyword pythonExClass	BaseException
442
-  syn keyword pythonExClass	Exception ArithmeticError
443
-  syn keyword pythonExClass	LookupError EnvironmentError
444
-
445
-  syn keyword pythonExClass	AssertionError AttributeError BufferError EOFError
446
-  syn keyword pythonExClass	FloatingPointError GeneratorExit IOError
447
-  syn keyword pythonExClass	ImportError IndexError KeyError
448
-  syn keyword pythonExClass	KeyboardInterrupt MemoryError NameError
449
-  syn keyword pythonExClass	NotImplementedError OSError OverflowError
450
-  syn keyword pythonExClass	ReferenceError RuntimeError StopIteration
451
-  syn keyword pythonExClass	SyntaxError IndentationError TabError
452
-  syn keyword pythonExClass	SystemError SystemExit TypeError
453
-  syn keyword pythonExClass	UnboundLocalError UnicodeError
454
-  syn keyword pythonExClass	UnicodeEncodeError UnicodeDecodeError
455
-  syn keyword pythonExClass	UnicodeTranslateError ValueError VMSError
456
-  syn keyword pythonExClass	WindowsError ZeroDivisionError
457
-
458
-  syn keyword pythonExClass	Warning UserWarning BytesWarning DeprecationWarning
459
-  syn keyword pythonExClass	PendingDepricationWarning SyntaxWarning
460
-  syn keyword pythonExClass	RuntimeWarning FutureWarning
461
-  syn keyword pythonExClass	ImportWarning UnicodeWarning
462
 endif
329
 endif
463
 
330
 
464
-if s:Enabled("g:python_slow_sync")
465
-  syn sync minlines=2000
466
-else
467
-  " This is fast but code inside triple quoted strings screws it up. It
468
-  " is impossible to fix because the only way to know if you are inside a
469
-  " triple quoted string is to start from the beginning of the file.
470
-  syn sync match pythonSync grouphere NONE "):$"
471
-  syn sync maxlines=200
472
-endif
331
+" Sync at the beginning of class, function, or method definition.
332
+syn sync match pythonSync grouphere NONE "^\s*\%(def\|class\)\s\+\h\w*\s*("
473
 
333
 
474
 if version >= 508 || !exists("did_python_syn_inits")
334
 if version >= 508 || !exists("did_python_syn_inits")
475
   if version <= 508
335
   if version <= 508
479
     command -nargs=+ HiLink hi def link <args>
339
     command -nargs=+ HiLink hi def link <args>
480
   endif
340
   endif
481
 
341
 
482
-  HiLink pythonStatement        Statement
483
-  HiLink pythonImport           Include
484
-  HiLink pythonFunction         Function
485
-  HiLink pythonConditional      Conditional
486
-  HiLink pythonRepeat           Repeat
487
-  HiLink pythonException        Exception
488
-  HiLink pythonOperator         Operator
489
-
490
-  HiLink pythonDecorator        Define
491
-  HiLink pythonDottedName       Function
492
-  HiLink pythonDot              Normal
493
-
494
-  HiLink pythonComment          Comment
495
-  if !s:Enabled("g:python_highlight_file_headers_as_comments")
496
-    HiLink pythonCoding           Special
497
-    HiLink pythonRun              Special
342
+  " The default highlight links.  Can be overridden later.
343
+  HiLink pythonStatement	Statement
344
+  HiLink pythonConditional	Conditional
345
+  HiLink pythonRepeat		Repeat
346
+  HiLink pythonOperator		Operator
347
+  if !exists("python_no_extra_operators_highlight")
348
+    HiLink pythonExtraOperator		Operator
349
+    HiLink pythonExtraPseudoOperator	Operator
498
   endif
350
   endif
499
-  HiLink pythonTodo             Todo
500
-
501
-  HiLink pythonError            Error
502
-  HiLink pythonIndentError      Error
503
-  HiLink pythonSpaceError       Error
504
-
505
-  HiLink pythonString           String
506
-  HiLink pythonRawString        String
507
-
508
-  HiLink pythonUniEscape        Special
509
-  HiLink pythonUniEscapeError   Error
510
-
511
-  if s:Python2Syntax()
512
-    HiLink pythonUniString          String
513
-    HiLink pythonUniRawString       String
514
-    HiLink pythonUniRawEscape       Special
515
-    HiLink pythonUniRawEscapeError  Error
516
-  else
517
-    HiLink pythonBytes              String
518
-    HiLink pythonRawBytes           String
519
-    HiLink pythonBytesContent       String
520
-    HiLink pythonBytesError         Error
521
-    HiLink pythonBytesEscape        Special
522
-    HiLink pythonBytesEscapeError   Error
351
+  HiLink pythonException	Exception
352
+  HiLink pythonInclude		Include
353
+  HiLink pythonDecorator	Define
354
+  HiLink pythonFunction		Function
355
+  HiLink pythonComment		Comment
356
+  if exists("python_shebang_header_highlight")
357
+    HiLink pythonRun		Special
358
+  endif
359
+  if exists("python_coding_header_highlight")
360
+    HiLink pythonCoding		Special
361
+  endif
362
+  HiLink pythonTodo		Todo
363
+  HiLink pythonString		String
364
+  HiLink pythonRawString	String
365
+  if !exists("python_no_string_format_highlight")
366
+    HiLink pythonStrFormat	Special
367
+  endif
368
+  if !exists("python_no_string_formatting_highlight")
369
+    HiLink pythonStrFormatting	Special
370
+  endif
371
+  if !exists("python_no_string_template_highlight")
372
+    HiLink pythonStrTemplate	Special
373
+  endif
374
+  HiLink pythonEscape		Special
375
+  if !exists("python_no_number_highlight")
376
+    HiLink pythonNumber		Number
377
+  endif
378
+  if !exists("python_no_builtin_highlight")
379
+    HiLink pythonBuiltin	Function
380
+  endif
381
+  if !exists("python_no_self_highlight")
382
+    HiLink pythonSelf		Identifier
383
+  endif
384
+  if !exists("python_no_exception_highlight")
385
+    HiLink pythonExceptions	Structure
386
+  endif
387
+  if exists("python_space_error_highlight")
388
+    HiLink pythonSpaceError	Error
389
+  endif
390
+  if !exists("python_no_doctest_highlight")
391
+    HiLink pythonDoctest	Special
392
+    HiLink pythonDoctestValue	Define
523
   endif
393
   endif
524
-
525
-  HiLink pythonStrFormatting    Special
526
-  HiLink pythonStrFormat        Special
527
-  HiLink pythonStrTemplate      Special
528
-
529
-  HiLink pythonDocTest          Special
530
-  HiLink pythonDocTest2         Special
531
-
532
-  HiLink pythonNumber           Number
533
-  HiLink pythonHexNumber        Number
534
-  HiLink pythonOctNumber        Number
535
-  HiLink pythonBinNumber        Number
536
-  HiLink pythonFloat            Float
537
-  HiLink pythonNumberError      Error
538
-  HiLink pythonOctError         Error
539
-  HiLink pythonHexError         Error
540
-  HiLink pythonBinError         Error
541
-
542
-  HiLink pythonBoolean          Boolean
543
-
544
-  HiLink pythonBuiltinObj       Structure
545
-  HiLink pythonBuiltinFunc      Function
546
-
547
-  HiLink pythonExClass          Structure
548
 
394
 
549
   delcommand HiLink
395
   delcommand HiLink
550
 endif
396
 endif
551
 
397
 
552
 let b:current_syntax = "python"
398
 let b:current_syntax = "python"
399
+
400
+let &cpo = s:cpo_save
401
+unlet s:cpo_save
402
+
403
+" vim:set sw=2 sts=2 ts=8 noet: