xref: /vim-8.2.3635/runtime/syntax/python.vim (revision b4ada79a)
1071d4279SBram Moolenaar" Vim syntax file
2071d4279SBram Moolenaar" Language:	Python
3541f92d6SBram Moolenaar" Maintainer:	Zvezdan Petkovic <[email protected]>
4*b4ada79aSBram Moolenaar" Last Change:	2016 Oct 29
5541f92d6SBram Moolenaar" Credits:	Neil Schemenauer <[email protected]>
65c73622aSBram Moolenaar"		Dmitry Vasiliev
7071d4279SBram Moolenaar"
85c73622aSBram Moolenaar"		This version is a major rewrite by Zvezdan Petkovic.
9071d4279SBram Moolenaar"
105c73622aSBram Moolenaar"		- introduced highlighting of doctests
115c73622aSBram Moolenaar"		- updated keywords, built-ins, and exceptions
125c73622aSBram Moolenaar"		- corrected regular expressions for
13071d4279SBram Moolenaar"
145c73622aSBram Moolenaar"		  * functions
155c73622aSBram Moolenaar"		  * decorators
165c73622aSBram Moolenaar"		  * strings
175c73622aSBram Moolenaar"		  * escapes
185c73622aSBram Moolenaar"		  * numbers
195c73622aSBram Moolenaar"		  * space error
20071d4279SBram Moolenaar"
215c73622aSBram Moolenaar"		- corrected synchronization
225c73622aSBram Moolenaar"		- more highlighting is ON by default, except
235c73622aSBram Moolenaar"		- space error highlighting is OFF by default
24071d4279SBram Moolenaar"
255c73622aSBram Moolenaar" Optional highlighting can be controlled using these variables.
26071d4279SBram Moolenaar"
275c73622aSBram Moolenaar"   let python_no_builtin_highlight = 1
285c73622aSBram Moolenaar"   let python_no_doctest_code_highlight = 1
295c73622aSBram Moolenaar"   let python_no_doctest_highlight = 1
305c73622aSBram Moolenaar"   let python_no_exception_highlight = 1
315c73622aSBram Moolenaar"   let python_no_number_highlight = 1
325c73622aSBram Moolenaar"   let python_space_error_highlight = 1
33071d4279SBram Moolenaar"
345c73622aSBram Moolenaar" All the options above can be switched on together.
35071d4279SBram Moolenaar"
36071d4279SBram Moolenaar"   let python_highlight_all = 1
37071d4279SBram Moolenaar"
38071d4279SBram Moolenaar
3989bcfda6SBram Moolenaar" quit when a syntax file was already loaded.
4089bcfda6SBram Moolenaarif exists("b:current_syntax")
41071d4279SBram Moolenaar  finish
42071d4279SBram Moolenaarendif
43071d4279SBram Moolenaar
4400659069SBram Moolenaar" We need nocompatible mode in order to continue lines with backslashes.
4500659069SBram Moolenaar" Original setting will be restored.
4600659069SBram Moolenaarlet s:cpo_save = &cpo
4700659069SBram Moolenaarset cpo&vim
4800659069SBram Moolenaar
49*b4ada79aSBram Moolenaarif exists("python_no_doctest_highlight")
50*b4ada79aSBram Moolenaar  let python_no_doctest_code_highlight = 1
51*b4ada79aSBram Moolenaarendif
52*b4ada79aSBram Moolenaar
53*b4ada79aSBram Moolenaarif exists("python_highlight_all")
54*b4ada79aSBram Moolenaar  if exists("python_no_builtin_highlight")
55*b4ada79aSBram Moolenaar    unlet python_no_builtin_highlight
56*b4ada79aSBram Moolenaar  endif
57*b4ada79aSBram Moolenaar  if exists("python_no_doctest_code_highlight")
58*b4ada79aSBram Moolenaar    unlet python_no_doctest_code_highlight
59*b4ada79aSBram Moolenaar  endif
60*b4ada79aSBram Moolenaar  if exists("python_no_doctest_highlight")
61*b4ada79aSBram Moolenaar    unlet python_no_doctest_highlight
62*b4ada79aSBram Moolenaar  endif
63*b4ada79aSBram Moolenaar  if exists("python_no_exception_highlight")
64*b4ada79aSBram Moolenaar    unlet python_no_exception_highlight
65*b4ada79aSBram Moolenaar  endif
66*b4ada79aSBram Moolenaar  if exists("python_no_number_highlight")
67*b4ada79aSBram Moolenaar    unlet python_no_number_highlight
68*b4ada79aSBram Moolenaar  endif
69*b4ada79aSBram Moolenaar  let python_space_error_highlight = 1
70*b4ada79aSBram Moolenaarendif
71*b4ada79aSBram Moolenaar
725c73622aSBram Moolenaar" Keep Python keywords in alphabetical order inside groups for easy
735c73622aSBram Moolenaar" comparison with the table in the 'Python Language Reference'
74f9132810SBram Moolenaar" https://docs.python.org/2/reference/lexical_analysis.html#keywords,
75f9132810SBram Moolenaar" https://docs.python.org/3/reference/lexical_analysis.html#keywords.
765c73622aSBram Moolenaar" Groups are in the order presented in NAMING CONVENTIONS in syntax.txt.
775c73622aSBram Moolenaar" Exceptions come last at the end of each group (class and def below).
785c73622aSBram Moolenaar"
795c73622aSBram Moolenaar" Keywords 'with' and 'as' are new in Python 2.6
805c73622aSBram Moolenaar" (use 'from __future__ import with_statement' in Python 2.5).
815c73622aSBram Moolenaar"
82f9132810SBram Moolenaar" Some compromises had to be made to support both Python 3 and 2.
83f9132810SBram Moolenaar" We include Python 3 features, but when a definition is duplicated,
845c73622aSBram Moolenaar" the last definition takes precedence.
855c73622aSBram Moolenaar"
86f9132810SBram Moolenaar" - 'False', 'None', and 'True' are keywords in Python 3 but they are
87f9132810SBram Moolenaar"   built-ins in 2 and will be highlighted as built-ins below.
88f9132810SBram Moolenaar" - 'exec' is a built-in in Python 3 and will be highlighted as
895c73622aSBram Moolenaar"   built-in below.
90f9132810SBram Moolenaar" - 'nonlocal' is a keyword in Python 3 and will be highlighted.
91f9132810SBram Moolenaar" - 'print' is a built-in in Python 3 and will be highlighted as
92f9132810SBram Moolenaar"   built-in below (use 'from __future__ import print_function' in 2)
93ca63501fSBram Moolenaar" - async and await were added in Python 3.5 and are soft keywords.
945c73622aSBram Moolenaar"
956f1d9a09SBram Moolenaarsyn keyword pythonStatement	False None True
965c73622aSBram Moolenaarsyn keyword pythonStatement	as assert break continue del exec global
975c73622aSBram Moolenaarsyn keyword pythonStatement	lambda nonlocal pass print return with yield
985c73622aSBram Moolenaarsyn keyword pythonStatement	class def nextgroup=pythonFunction skipwhite
995c73622aSBram Moolenaarsyn keyword pythonConditional	elif else if
100071d4279SBram Moolenaarsyn keyword pythonRepeat	for while
101071d4279SBram Moolenaarsyn keyword pythonOperator	and in is not or
1025c73622aSBram Moolenaarsyn keyword pythonException	except finally raise try
1035c73622aSBram Moolenaarsyn keyword pythonInclude	from import
104ca63501fSBram Moolenaarsyn keyword pythonAsync		async await
105071d4279SBram Moolenaar
1069c102387SBram Moolenaar" Decorators (new in Python 2.4)
1075c73622aSBram Moolenaar" A dot must be allowed because of @MyClass.myfunc decorators.
108*b4ada79aSBram Moolenaarsyn match   pythonDecorator	"@" display contained
109*b4ada79aSBram Moolenaarsyn match   pythonDecoratorName	"@\s*\h\%(\w\|\.\)*" display contains=pythonDecorator
110e4a3bcf2SBram Moolenaar
111*b4ada79aSBram Moolenaar" Python 3.5 introduced the use of the same symbol for matrix multiplication:
112*b4ada79aSBram Moolenaar" https://www.python.org/dev/peps/pep-0465/.  We now have to exclude the
113*b4ada79aSBram Moolenaar" symbol from highlighting when used in that context.
114*b4ada79aSBram Moolenaar" Single line multiplication.
115*b4ada79aSBram Moolenaarsyn match   pythonMatrixMultiply
116*b4ada79aSBram Moolenaar      \ "\%(\w\|[])]\)\s*@"
117*b4ada79aSBram Moolenaar      \ contains=ALLBUT,pythonDecoratorName,pythonDecorator,pythonFunction,pythonDoctestValue
118*b4ada79aSBram Moolenaar      \ transparent
119*b4ada79aSBram Moolenaar" Multiplication continued on the next line after backslash.
120*b4ada79aSBram Moolenaarsyn match   pythonMatrixMultiply
121*b4ada79aSBram Moolenaar      \ "[^\\]\\\s*\n\%(\s*\.\.\.\s\)\=\s\+@"
122*b4ada79aSBram Moolenaar      \ contains=ALLBUT,pythonDecoratorName,pythonDecorator,pythonFunction,pythonDoctestValue
123*b4ada79aSBram Moolenaar      \ transparent
124*b4ada79aSBram Moolenaar" Multiplication in a parenthesized expression over multiple lines with @ at
125*b4ada79aSBram Moolenaar" the start of each continued line; very similar to decorators and complex.
126*b4ada79aSBram Moolenaarsyn match   pythonMatrixMultiply
127*b4ada79aSBram Moolenaar      \ "^\s*\%(\%(>>>\|\.\.\.\)\s\+\)\=\zs\%(\h\|\%(\h\|[[(]\).\{-}\%(\w\|[])]\)\)\s*\n\%(\s*\.\.\.\s\)\=\s\+@\%(.\{-}\n\%(\s*\.\.\.\s\)\=\s\+@\)*"
128*b4ada79aSBram Moolenaar      \ contains=ALLBUT,pythonDecoratorName,pythonDecorator,pythonFunction,pythonDoctestValue
129*b4ada79aSBram Moolenaar      \ transparent
130*b4ada79aSBram Moolenaar
131*b4ada79aSBram Moolenaarsyn match   pythonFunction	"\h\w*" display contained
1329c102387SBram Moolenaar
1335c73622aSBram Moolenaarsyn match   pythonComment	"#.*$" contains=pythonTodo,@Spell
1345c73622aSBram Moolenaarsyn keyword pythonTodo		FIXME NOTE NOTES TODO XXX contained
1355c73622aSBram Moolenaar
1365c73622aSBram Moolenaar" Triple-quoted strings can contain doctests.
137541f92d6SBram Moolenaarsyn region  pythonString matchgroup=pythonQuotes
1385c73622aSBram Moolenaar      \ start=+[uU]\=\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1"
1395c73622aSBram Moolenaar      \ contains=pythonEscape,@Spell
140541f92d6SBram Moolenaarsyn region  pythonString matchgroup=pythonTripleQuotes
1415c73622aSBram Moolenaar      \ start=+[uU]\=\z('''\|"""\)+ end="\z1" keepend
1425c73622aSBram Moolenaar      \ contains=pythonEscape,pythonSpaceError,pythonDoctest,@Spell
143541f92d6SBram Moolenaarsyn region  pythonRawString matchgroup=pythonQuotes
1445c73622aSBram Moolenaar      \ start=+[uU]\=[rR]\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1"
1455c73622aSBram Moolenaar      \ contains=@Spell
146541f92d6SBram Moolenaarsyn region  pythonRawString matchgroup=pythonTripleQuotes
1475c73622aSBram Moolenaar      \ start=+[uU]\=[rR]\z('''\|"""\)+ end="\z1" keepend
1485c73622aSBram Moolenaar      \ contains=pythonSpaceError,pythonDoctest,@Spell
1495c73622aSBram Moolenaar
150071d4279SBram Moolenaarsyn match   pythonEscape	+\\[abfnrtv'"\\]+ contained
151071d4279SBram Moolenaarsyn match   pythonEscape	"\\\o\{1,3}" contained
152071d4279SBram Moolenaarsyn match   pythonEscape	"\\x\x\{2}" contained
1535c73622aSBram Moolenaarsyn match   pythonEscape	"\%(\\u\x\{4}\|\\U\x\{8}\)" contained
1545c73622aSBram Moolenaar" Python allows case-insensitive Unicode IDs: http://www.unicode.org/charts/
155541f92d6SBram Moolenaarsyn match   pythonEscape	"\\N{\a\+\%(\s\a\+\)*}" contained
156071d4279SBram Moolenaarsyn match   pythonEscape	"\\$"
157071d4279SBram Moolenaar
1585c73622aSBram Moolenaar" It is very important to understand all details before changing the
1595c73622aSBram Moolenaar" regular expressions below or their order.
1605c73622aSBram Moolenaar" The word boundaries are *not* the floating-point number boundaries
1615c73622aSBram Moolenaar" because of a possible leading or trailing decimal point.
1625c73622aSBram Moolenaar" The expressions below ensure that all valid number literals are
1635c73622aSBram Moolenaar" highlighted, and invalid number literals are not.  For example,
1645c73622aSBram Moolenaar"
1655c73622aSBram Moolenaar" - a decimal point in '4.' at the end of a line is highlighted,
1665c73622aSBram Moolenaar" - a second dot in 1.0.0 is not highlighted,
1675c73622aSBram Moolenaar" - 08 is not highlighted,
1685c73622aSBram Moolenaar" - 08e0 or 08j are highlighted,
1695c73622aSBram Moolenaar"
1705c73622aSBram Moolenaar" and so on, as specified in the 'Python Language Reference'.
171f9132810SBram Moolenaar" https://docs.python.org/2/reference/lexical_analysis.html#numeric-literals
172f9132810SBram Moolenaar" https://docs.python.org/3/reference/lexical_analysis.html#numeric-literals
1735c73622aSBram Moolenaarif !exists("python_no_number_highlight")
174071d4279SBram Moolenaar  " numbers (including longs and complex)
1755c73622aSBram Moolenaar  syn match   pythonNumber	"\<0[oO]\=\o\+[Ll]\=\>"
1765c73622aSBram Moolenaar  syn match   pythonNumber	"\<0[xX]\x\+[Ll]\=\>"
1775c73622aSBram Moolenaar  syn match   pythonNumber	"\<0[bB][01]\+[Ll]\=\>"
1785c73622aSBram Moolenaar  syn match   pythonNumber	"\<\%([1-9]\d*\|0\)[Ll]\=\>"
1795c73622aSBram Moolenaar  syn match   pythonNumber	"\<\d\+[jJ]\>"
1805c73622aSBram Moolenaar  syn match   pythonNumber	"\<\d\+[eE][+-]\=\d\+[jJ]\=\>"
1815c73622aSBram Moolenaar  syn match   pythonNumber
1825c73622aSBram Moolenaar	\ "\<\d\+\.\%([eE][+-]\=\d\+\)\=[jJ]\=\%(\W\|$\)\@="
1835c73622aSBram Moolenaar  syn match   pythonNumber
184f9132810SBram Moolenaar	\ "\%(^\|\W\)\zs\d*\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>"
185071d4279SBram Moolenaarendif
186071d4279SBram Moolenaar
1875c73622aSBram Moolenaar" Group the built-ins in the order in the 'Python Library Reference' for
1885c73622aSBram Moolenaar" easier comparison.
189f9132810SBram Moolenaar" https://docs.python.org/2/library/constants.html
190f9132810SBram Moolenaar" https://docs.python.org/3/library/constants.html
191f9132810SBram Moolenaar" http://docs.python.org/2/library/functions.html
192f9132810SBram Moolenaar" http://docs.python.org/3/library/functions.html
193f9132810SBram Moolenaar" http://docs.python.org/2/library/functions.html#non-essential-built-in-functions
194f9132810SBram Moolenaar" http://docs.python.org/3/library/functions.html#non-essential-built-in-functions
1955c73622aSBram Moolenaar" Python built-in functions are in alphabetical order.
1965c73622aSBram Moolenaarif !exists("python_no_builtin_highlight")
1975c73622aSBram Moolenaar  " built-in constants
198f9132810SBram Moolenaar  " 'False', 'True', and 'None' are also reserved words in Python 3
1995c73622aSBram Moolenaar  syn keyword pythonBuiltin	False True None
2005c73622aSBram Moolenaar  syn keyword pythonBuiltin	NotImplemented Ellipsis __debug__
2015c73622aSBram Moolenaar  " built-in functions
202f9132810SBram Moolenaar  syn keyword pythonBuiltin	abs all any bin bool bytearray callable chr
203f9132810SBram Moolenaar  syn keyword pythonBuiltin	classmethod compile complex delattr dict dir
204f9132810SBram Moolenaar  syn keyword pythonBuiltin	divmod enumerate eval filter float format
2055c73622aSBram Moolenaar  syn keyword pythonBuiltin	frozenset getattr globals hasattr hash
2065c73622aSBram Moolenaar  syn keyword pythonBuiltin	help hex id input int isinstance
2075c73622aSBram Moolenaar  syn keyword pythonBuiltin	issubclass iter len list locals map max
208f9132810SBram Moolenaar  syn keyword pythonBuiltin	memoryview min next object oct open ord pow
209f9132810SBram Moolenaar  syn keyword pythonBuiltin	print property range repr reversed round set
2105c73622aSBram Moolenaar  syn keyword pythonBuiltin	setattr slice sorted staticmethod str
2115c73622aSBram Moolenaar  syn keyword pythonBuiltin	sum super tuple type vars zip __import__
212f9132810SBram Moolenaar  " Python 2 only
213f9132810SBram Moolenaar  syn keyword pythonBuiltin	basestring cmp execfile file
2145c73622aSBram Moolenaar  syn keyword pythonBuiltin	long raw_input reduce reload unichr
2155c73622aSBram Moolenaar  syn keyword pythonBuiltin	unicode xrange
216f9132810SBram Moolenaar  " Python 3 only
217f9132810SBram Moolenaar  syn keyword pythonBuiltin	ascii bytes exec
218f9132810SBram Moolenaar  " non-essential built-in functions; Python 2 only
2195c73622aSBram Moolenaar  syn keyword pythonBuiltin	apply buffer coerce intern
22077cdfd10SBram Moolenaar  " avoid highlighting attributes as builtins
221*b4ada79aSBram Moolenaar  syn match   pythonAttribute	/\.\h\w*/hs=s+1
222*b4ada79aSBram Moolenaar	\ contains=ALLBUT,pythonBuiltin,pythonFunction,pythonAsync
223*b4ada79aSBram Moolenaar	\ transparent
224071d4279SBram Moolenaarendif
225071d4279SBram Moolenaar
2265c73622aSBram Moolenaar" From the 'Python Library Reference' class hierarchy at the bottom.
227f9132810SBram Moolenaar" http://docs.python.org/2/library/exceptions.html
228f9132810SBram Moolenaar" http://docs.python.org/3/library/exceptions.html
2295c73622aSBram Moolenaarif !exists("python_no_exception_highlight")
230f9132810SBram Moolenaar  " builtin base exceptions (used mostly as base classes for other exceptions)
2315c73622aSBram Moolenaar  syn keyword pythonExceptions	BaseException Exception
232f9132810SBram Moolenaar  syn keyword pythonExceptions	ArithmeticError BufferError
2335c73622aSBram Moolenaar  syn keyword pythonExceptions	LookupError
234f9132810SBram Moolenaar  " builtin base exceptions removed in Python 3
235f9132810SBram Moolenaar  syn keyword pythonExceptions	EnvironmentError StandardError
2365c73622aSBram Moolenaar  " builtin exceptions (actually raised)
237f9132810SBram Moolenaar  syn keyword pythonExceptions	AssertionError AttributeError
2385c73622aSBram Moolenaar  syn keyword pythonExceptions	EOFError FloatingPointError GeneratorExit
239f9132810SBram Moolenaar  syn keyword pythonExceptions	ImportError IndentationError
2405c73622aSBram Moolenaar  syn keyword pythonExceptions	IndexError KeyError KeyboardInterrupt
2415c73622aSBram Moolenaar  syn keyword pythonExceptions	MemoryError NameError NotImplementedError
2425c73622aSBram Moolenaar  syn keyword pythonExceptions	OSError OverflowError ReferenceError
2435c73622aSBram Moolenaar  syn keyword pythonExceptions	RuntimeError StopIteration SyntaxError
2445c73622aSBram Moolenaar  syn keyword pythonExceptions	SystemError SystemExit TabError TypeError
2455c73622aSBram Moolenaar  syn keyword pythonExceptions	UnboundLocalError UnicodeError
2465c73622aSBram Moolenaar  syn keyword pythonExceptions	UnicodeDecodeError UnicodeEncodeError
247f9132810SBram Moolenaar  syn keyword pythonExceptions	UnicodeTranslateError ValueError
248f9132810SBram Moolenaar  syn keyword pythonExceptions	ZeroDivisionError
249f9132810SBram Moolenaar  " builtin OS exceptions in Python 3
250f9132810SBram Moolenaar  syn keyword pythonExceptions	BlockingIOError BrokenPipeError
251f9132810SBram Moolenaar  syn keyword pythonExceptions	ChildProcessError ConnectionAbortedError
252f9132810SBram Moolenaar  syn keyword pythonExceptions	ConnectionError ConnectionRefusedError
253f9132810SBram Moolenaar  syn keyword pythonExceptions	ConnectionResetError FileExistsError
254f9132810SBram Moolenaar  syn keyword pythonExceptions	FileNotFoundError InterruptedError
255f9132810SBram Moolenaar  syn keyword pythonExceptions	IsADirectoryError NotADirectoryError
256f9132810SBram Moolenaar  syn keyword pythonExceptions	PermissionError ProcessLookupError
257ca63501fSBram Moolenaar  syn keyword pythonExceptions	RecursionError StopAsyncIteration
258f9132810SBram Moolenaar  syn keyword pythonExceptions	TimeoutError
259f9132810SBram Moolenaar  " builtin exceptions deprecated/removed in Python 3
260f9132810SBram Moolenaar  syn keyword pythonExceptions	IOError VMSError WindowsError
2615c73622aSBram Moolenaar  " builtin warnings
2625c73622aSBram Moolenaar  syn keyword pythonExceptions	BytesWarning DeprecationWarning FutureWarning
2635c73622aSBram Moolenaar  syn keyword pythonExceptions	ImportWarning PendingDeprecationWarning
2645c73622aSBram Moolenaar  syn keyword pythonExceptions	RuntimeWarning SyntaxWarning UnicodeWarning
2655c73622aSBram Moolenaar  syn keyword pythonExceptions	UserWarning Warning
266f9132810SBram Moolenaar  " builtin warnings in Python 3
267f9132810SBram Moolenaar  syn keyword pythonExceptions	ResourceWarning
268071d4279SBram Moolenaarendif
269071d4279SBram Moolenaar
2705c73622aSBram Moolenaarif exists("python_space_error_highlight")
271071d4279SBram Moolenaar  " trailing whitespace
2725c73622aSBram Moolenaar  syn match   pythonSpaceError	display excludenl "\s\+$"
273071d4279SBram Moolenaar  " mixed tabs and spaces
274071d4279SBram Moolenaar  syn match   pythonSpaceError	display " \+\t"
275071d4279SBram Moolenaar  syn match   pythonSpaceError	display "\t\+ "
276071d4279SBram Moolenaarendif
277071d4279SBram Moolenaar
2785c73622aSBram Moolenaar" Do not spell doctests inside strings.
2795c73622aSBram Moolenaar" Notice that the end of a string, either ''', or """, will end the contained
2805c73622aSBram Moolenaar" doctest too.  Thus, we do *not* need to have it as an end pattern.
2815c73622aSBram Moolenaarif !exists("python_no_doctest_highlight")
28234700a6aSBram Moolenaar  if !exists("python_no_doctest_code_highlight")
2835c73622aSBram Moolenaar    syn region pythonDoctest
2845c73622aSBram Moolenaar	  \ start="^\s*>>>\s" end="^\s*$"
285*b4ada79aSBram Moolenaar	  \ contained contains=ALLBUT,pythonDoctest,pythonFunction,@Spell
2865c73622aSBram Moolenaar    syn region pythonDoctestValue
2875c73622aSBram Moolenaar	  \ start=+^\s*\%(>>>\s\|\.\.\.\s\|"""\|'''\)\@!\S\++ end="$"
2885c73622aSBram Moolenaar	  \ contained
2895c73622aSBram Moolenaar  else
2905c73622aSBram Moolenaar    syn region pythonDoctest
2915c73622aSBram Moolenaar	  \ start="^\s*>>>" end="^\s*$"
2925c73622aSBram Moolenaar	  \ contained contains=@NoSpell
2935c73622aSBram Moolenaar  endif
2945c73622aSBram Moolenaarendif
2955c73622aSBram Moolenaar
2965c73622aSBram Moolenaar" Sync at the beginning of class, function, or method definition.
297*b4ada79aSBram Moolenaarsyn sync match pythonSync grouphere NONE "^\%(def\|class\)\s\+\h\w*\s*[(:]"
298071d4279SBram Moolenaar
2995c73622aSBram Moolenaar" The default highlight links.  Can be overridden later.
300f37506f6SBram Moolenaarhi def link pythonStatement		Statement
301f37506f6SBram Moolenaarhi def link pythonConditional		Conditional
302f37506f6SBram Moolenaarhi def link pythonRepeat		Repeat
303f37506f6SBram Moolenaarhi def link pythonOperator		Operator
304f37506f6SBram Moolenaarhi def link pythonException		Exception
305f37506f6SBram Moolenaarhi def link pythonInclude		Include
306f37506f6SBram Moolenaarhi def link pythonAsync			Statement
307f37506f6SBram Moolenaarhi def link pythonDecorator		Define
308f37506f6SBram Moolenaarhi def link pythonDecoratorName		Function
309f37506f6SBram Moolenaarhi def link pythonFunction		Function
310f37506f6SBram Moolenaarhi def link pythonComment		Comment
311f37506f6SBram Moolenaarhi def link pythonTodo			Todo
312f37506f6SBram Moolenaarhi def link pythonString		String
313f37506f6SBram Moolenaarhi def link pythonRawString		String
314f37506f6SBram Moolenaarhi def link pythonQuotes		String
315f37506f6SBram Moolenaarhi def link pythonTripleQuotes		pythonQuotes
316f37506f6SBram Moolenaarhi def link pythonEscape		Special
3175c73622aSBram Moolenaarif !exists("python_no_number_highlight")
318f37506f6SBram Moolenaar  hi def link pythonNumber		Number
319071d4279SBram Moolenaarendif
3205c73622aSBram Moolenaarif !exists("python_no_builtin_highlight")
321f37506f6SBram Moolenaar  hi def link pythonBuiltin		Function
322071d4279SBram Moolenaarendif
3235c73622aSBram Moolenaarif !exists("python_no_exception_highlight")
324f37506f6SBram Moolenaar  hi def link pythonExceptions		Structure
325071d4279SBram Moolenaarendif
3265c73622aSBram Moolenaarif exists("python_space_error_highlight")
327f37506f6SBram Moolenaar  hi def link pythonSpaceError		Error
328071d4279SBram Moolenaarendif
3295c73622aSBram Moolenaarif !exists("python_no_doctest_highlight")
330f37506f6SBram Moolenaar  hi def link pythonDoctest		Special
331f37506f6SBram Moolenaar  hi def link pythonDoctestValue	Define
3325c73622aSBram Moolenaarendif
333071d4279SBram Moolenaar
334071d4279SBram Moolenaarlet b:current_syntax = "python"
335071d4279SBram Moolenaar
33600659069SBram Moolenaarlet &cpo = s:cpo_save
33700659069SBram Moolenaarunlet s:cpo_save
33800659069SBram Moolenaar
3395c73622aSBram Moolenaar" vim:set sw=2 sts=2 ts=8 noet:
340