| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " Vim syntax file | 
					
						
							|  |  |  | " Language:	Python | 
					
						
							| 
									
										
										
										
											2015-06-19 13:27:23 +02:00
										 |  |  | " Maintainer:	Zvezdan Petkovic <zpetkovic@acm.org> | 
					
						
							| 
									
										
										
										
											2016-10-30 21:55:26 +01:00
										 |  |  | " Last Change:	2016 Oct 29 | 
					
						
							| 
									
										
										
										
											2015-06-19 13:27:23 +02:00
										 |  |  | " Credits:	Neil Schemenauer <nas@python.ca> | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | "		Dmitry Vasiliev | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | "		This version is a major rewrite by Zvezdan Petkovic. | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | "		- introduced highlighting of doctests | 
					
						
							|  |  |  | "		- updated keywords, built-ins, and exceptions | 
					
						
							|  |  |  | "		- corrected regular expressions for | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | "		  * functions | 
					
						
							|  |  |  | "		  * decorators | 
					
						
							|  |  |  | "		  * strings | 
					
						
							|  |  |  | "		  * escapes | 
					
						
							|  |  |  | "		  * numbers | 
					
						
							|  |  |  | "		  * space error | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | "		- corrected synchronization | 
					
						
							|  |  |  | "		- more highlighting is ON by default, except | 
					
						
							|  |  |  | "		- space error highlighting is OFF by default | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | " Optional highlighting can be controlled using these variables. | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | "   let python_no_builtin_highlight = 1 | 
					
						
							|  |  |  | "   let python_no_doctest_code_highlight = 1 | 
					
						
							|  |  |  | "   let python_no_doctest_highlight = 1 | 
					
						
							|  |  |  | "   let python_no_exception_highlight = 1 | 
					
						
							|  |  |  | "   let python_no_number_highlight = 1 | 
					
						
							|  |  |  | "   let python_space_error_highlight = 1 | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | " All the options above can be switched on together. | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | "   let python_highlight_all = 1 | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | " quit when a syntax file was already loaded. | 
					
						
							|  |  |  | if exists("b:current_syntax") | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |   finish | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-21 22:34:02 +02:00
										 |  |  | " We need nocompatible mode in order to continue lines with backslashes. | 
					
						
							|  |  |  | " Original setting will be restored. | 
					
						
							|  |  |  | let s:cpo_save = &cpo | 
					
						
							|  |  |  | set cpo&vim | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-30 21:55:26 +01:00
										 |  |  | if exists("python_no_doctest_highlight") | 
					
						
							|  |  |  |   let python_no_doctest_code_highlight = 1 | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if exists("python_highlight_all") | 
					
						
							|  |  |  |   if exists("python_no_builtin_highlight") | 
					
						
							|  |  |  |     unlet python_no_builtin_highlight | 
					
						
							|  |  |  |   endif | 
					
						
							|  |  |  |   if exists("python_no_doctest_code_highlight") | 
					
						
							|  |  |  |     unlet python_no_doctest_code_highlight | 
					
						
							|  |  |  |   endif | 
					
						
							|  |  |  |   if exists("python_no_doctest_highlight") | 
					
						
							|  |  |  |     unlet python_no_doctest_highlight | 
					
						
							|  |  |  |   endif | 
					
						
							|  |  |  |   if exists("python_no_exception_highlight") | 
					
						
							|  |  |  |     unlet python_no_exception_highlight | 
					
						
							|  |  |  |   endif | 
					
						
							|  |  |  |   if exists("python_no_number_highlight") | 
					
						
							|  |  |  |     unlet python_no_number_highlight | 
					
						
							|  |  |  |   endif | 
					
						
							|  |  |  |   let python_space_error_highlight = 1 | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | " Keep Python keywords in alphabetical order inside groups for easy | 
					
						
							|  |  |  | " comparison with the table in the 'Python Language Reference' | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  | " https://docs.python.org/2/reference/lexical_analysis.html#keywords, | 
					
						
							|  |  |  | " https://docs.python.org/3/reference/lexical_analysis.html#keywords. | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | " Groups are in the order presented in NAMING CONVENTIONS in syntax.txt. | 
					
						
							|  |  |  | " Exceptions come last at the end of each group (class and def below). | 
					
						
							|  |  |  | " | 
					
						
							|  |  |  | " Keywords 'with' and 'as' are new in Python 2.6 | 
					
						
							|  |  |  | " (use 'from __future__ import with_statement' in Python 2.5). | 
					
						
							|  |  |  | " | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  | " Some compromises had to be made to support both Python 3 and 2. | 
					
						
							|  |  |  | " We include Python 3 features, but when a definition is duplicated, | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | " the last definition takes precedence. | 
					
						
							|  |  |  | " | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  | " - 'False', 'None', and 'True' are keywords in Python 3 but they are | 
					
						
							|  |  |  | "   built-ins in 2 and will be highlighted as built-ins below. | 
					
						
							|  |  |  | " - 'exec' is a built-in in Python 3 and will be highlighted as | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | "   built-in below. | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  | " - 'nonlocal' is a keyword in Python 3 and will be highlighted. | 
					
						
							|  |  |  | " - 'print' is a built-in in Python 3 and will be highlighted as | 
					
						
							|  |  |  | "   built-in below (use 'from __future__ import print_function' in 2) | 
					
						
							| 
									
										
										
										
											2015-09-25 20:34:21 +02:00
										 |  |  | " - async and await were added in Python 3.5 and are soft keywords. | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | " | 
					
						
							| 
									
										
										
										
											2016-07-24 14:12:38 +02:00
										 |  |  | syn keyword pythonStatement	False None True | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | syn keyword pythonStatement	as assert break continue del exec global | 
					
						
							|  |  |  | syn keyword pythonStatement	lambda nonlocal pass print return with yield | 
					
						
							|  |  |  | syn keyword pythonStatement	class def nextgroup=pythonFunction skipwhite | 
					
						
							|  |  |  | syn keyword pythonConditional	elif else if | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | syn keyword pythonRepeat	for while | 
					
						
							|  |  |  | syn keyword pythonOperator	and in is not or | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | syn keyword pythonException	except finally raise try | 
					
						
							|  |  |  | syn keyword pythonInclude	from import | 
					
						
							| 
									
										
										
										
											2015-09-25 20:34:21 +02:00
										 |  |  | syn keyword pythonAsync		async await | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-05-03 21:26:49 +00:00
										 |  |  | " Decorators (new in Python 2.4) | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | " A dot must be allowed because of @MyClass.myfunc decorators. | 
					
						
							| 
									
										
										
										
											2016-10-30 21:55:26 +01:00
										 |  |  | syn match   pythonDecorator	"@" display contained | 
					
						
							|  |  |  | syn match   pythonDecoratorName	"@\s*\h\%(\w\|\.\)*" display contains=pythonDecorator | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Python 3.5 introduced the use of the same symbol for matrix multiplication: | 
					
						
							|  |  |  | " https://www.python.org/dev/peps/pep-0465/.  We now have to exclude the | 
					
						
							|  |  |  | " symbol from highlighting when used in that context. | 
					
						
							|  |  |  | " Single line multiplication. | 
					
						
							|  |  |  | syn match   pythonMatrixMultiply | 
					
						
							|  |  |  |       \ "\%(\w\|[])]\)\s*@" | 
					
						
							|  |  |  |       \ contains=ALLBUT,pythonDecoratorName,pythonDecorator,pythonFunction,pythonDoctestValue | 
					
						
							|  |  |  |       \ transparent | 
					
						
							|  |  |  | " Multiplication continued on the next line after backslash. | 
					
						
							|  |  |  | syn match   pythonMatrixMultiply | 
					
						
							|  |  |  |       \ "[^\\]\\\s*\n\%(\s*\.\.\.\s\)\=\s\+@" | 
					
						
							|  |  |  |       \ contains=ALLBUT,pythonDecoratorName,pythonDecorator,pythonFunction,pythonDoctestValue | 
					
						
							|  |  |  |       \ transparent | 
					
						
							|  |  |  | " Multiplication in a parenthesized expression over multiple lines with @ at | 
					
						
							|  |  |  | " the start of each continued line; very similar to decorators and complex. | 
					
						
							|  |  |  | syn match   pythonMatrixMultiply | 
					
						
							|  |  |  |       \ "^\s*\%(\%(>>>\|\.\.\.\)\s\+\)\=\zs\%(\h\|\%(\h\|[[(]\).\{-}\%(\w\|[])]\)\)\s*\n\%(\s*\.\.\.\s\)\=\s\+@\%(.\{-}\n\%(\s*\.\.\.\s\)\=\s\+@\)*" | 
					
						
							|  |  |  |       \ contains=ALLBUT,pythonDecoratorName,pythonDecorator,pythonFunction,pythonDoctestValue | 
					
						
							|  |  |  |       \ transparent | 
					
						
							| 
									
										
										
										
											2016-08-26 19:52:37 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-30 21:55:26 +01:00
										 |  |  | syn match   pythonFunction	"\h\w*" display contained | 
					
						
							| 
									
										
										
										
											2006-05-03 21:26:49 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | syn match   pythonComment	"#.*$" contains=pythonTodo,@Spell | 
					
						
							|  |  |  | syn keyword pythonTodo		FIXME NOTE NOTES TODO XXX contained | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Triple-quoted strings can contain doctests. | 
					
						
							| 
									
										
										
										
											2015-06-19 13:27:23 +02:00
										 |  |  | syn region  pythonString matchgroup=pythonQuotes | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |       \ start=+[uU]\=\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1" | 
					
						
							|  |  |  |       \ contains=pythonEscape,@Spell | 
					
						
							| 
									
										
										
										
											2015-06-19 13:27:23 +02:00
										 |  |  | syn region  pythonString matchgroup=pythonTripleQuotes | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |       \ start=+[uU]\=\z('''\|"""\)+ end="\z1" keepend | 
					
						
							|  |  |  |       \ contains=pythonEscape,pythonSpaceError,pythonDoctest,@Spell | 
					
						
							| 
									
										
										
										
											2015-06-19 13:27:23 +02:00
										 |  |  | syn region  pythonRawString matchgroup=pythonQuotes | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |       \ start=+[uU]\=[rR]\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1" | 
					
						
							|  |  |  |       \ contains=@Spell | 
					
						
							| 
									
										
										
										
											2015-06-19 13:27:23 +02:00
										 |  |  | syn region  pythonRawString matchgroup=pythonTripleQuotes | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |       \ start=+[uU]\=[rR]\z('''\|"""\)+ end="\z1" keepend | 
					
						
							|  |  |  |       \ contains=pythonSpaceError,pythonDoctest,@Spell | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn match   pythonEscape	+\\[abfnrtv'"\\]+ contained | 
					
						
							|  |  |  | syn match   pythonEscape	"\\\o\{1,3}" contained | 
					
						
							|  |  |  | syn match   pythonEscape	"\\x\x\{2}" contained | 
					
						
							|  |  |  | syn match   pythonEscape	"\%(\\u\x\{4}\|\\U\x\{8}\)" contained | 
					
						
							|  |  |  | " Python allows case-insensitive Unicode IDs: http://www.unicode.org/charts/ | 
					
						
							| 
									
										
										
										
											2015-06-19 13:27:23 +02:00
										 |  |  | syn match   pythonEscape	"\\N{\a\+\%(\s\a\+\)*}" contained | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | syn match   pythonEscape	"\\$" | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | " It is very important to understand all details before changing the | 
					
						
							|  |  |  | " regular expressions below or their order. | 
					
						
							|  |  |  | " The word boundaries are *not* the floating-point number boundaries | 
					
						
							|  |  |  | " because of a possible leading or trailing decimal point. | 
					
						
							|  |  |  | " The expressions below ensure that all valid number literals are | 
					
						
							|  |  |  | " highlighted, and invalid number literals are not.  For example, | 
					
						
							|  |  |  | " | 
					
						
							|  |  |  | " - a decimal point in '4.' at the end of a line is highlighted, | 
					
						
							|  |  |  | " - a second dot in 1.0.0 is not highlighted, | 
					
						
							|  |  |  | " - 08 is not highlighted, | 
					
						
							|  |  |  | " - 08e0 or 08j are highlighted, | 
					
						
							|  |  |  | " | 
					
						
							|  |  |  | " and so on, as specified in the 'Python Language Reference'. | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  | " https://docs.python.org/2/reference/lexical_analysis.html#numeric-literals | 
					
						
							|  |  |  | " https://docs.python.org/3/reference/lexical_analysis.html#numeric-literals | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | if !exists("python_no_number_highlight") | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |   " numbers (including longs and complex) | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |   syn match   pythonNumber	"\<0[oO]\=\o\+[Ll]\=\>" | 
					
						
							|  |  |  |   syn match   pythonNumber	"\<0[xX]\x\+[Ll]\=\>" | 
					
						
							|  |  |  |   syn match   pythonNumber	"\<0[bB][01]\+[Ll]\=\>" | 
					
						
							|  |  |  |   syn match   pythonNumber	"\<\%([1-9]\d*\|0\)[Ll]\=\>" | 
					
						
							|  |  |  |   syn match   pythonNumber	"\<\d\+[jJ]\>" | 
					
						
							|  |  |  |   syn match   pythonNumber	"\<\d\+[eE][+-]\=\d\+[jJ]\=\>" | 
					
						
							|  |  |  |   syn match   pythonNumber | 
					
						
							|  |  |  | 	\ "\<\d\+\.\%([eE][+-]\=\d\+\)\=[jJ]\=\%(\W\|$\)\@=" | 
					
						
							|  |  |  |   syn match   pythonNumber | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  | 	\ "\%(^\|\W\)\zs\d*\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>" | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | " Group the built-ins in the order in the 'Python Library Reference' for | 
					
						
							|  |  |  | " easier comparison. | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  | " https://docs.python.org/2/library/constants.html | 
					
						
							|  |  |  | " https://docs.python.org/3/library/constants.html | 
					
						
							|  |  |  | " http://docs.python.org/2/library/functions.html | 
					
						
							|  |  |  | " http://docs.python.org/3/library/functions.html | 
					
						
							|  |  |  | " http://docs.python.org/2/library/functions.html#non-essential-built-in-functions | 
					
						
							|  |  |  | " http://docs.python.org/3/library/functions.html#non-essential-built-in-functions | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | " Python built-in functions are in alphabetical order. | 
					
						
							|  |  |  | if !exists("python_no_builtin_highlight") | 
					
						
							|  |  |  |   " built-in constants | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  |   " 'False', 'True', and 'None' are also reserved words in Python 3 | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |   syn keyword pythonBuiltin	False True None | 
					
						
							|  |  |  |   syn keyword pythonBuiltin	NotImplemented Ellipsis __debug__ | 
					
						
							|  |  |  |   " built-in functions | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  |   syn keyword pythonBuiltin	abs all any bin bool bytearray callable chr | 
					
						
							|  |  |  |   syn keyword pythonBuiltin	classmethod compile complex delattr dict dir | 
					
						
							|  |  |  |   syn keyword pythonBuiltin	divmod enumerate eval filter float format | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |   syn keyword pythonBuiltin	frozenset getattr globals hasattr hash | 
					
						
							|  |  |  |   syn keyword pythonBuiltin	help hex id input int isinstance | 
					
						
							|  |  |  |   syn keyword pythonBuiltin	issubclass iter len list locals map max | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  |   syn keyword pythonBuiltin	memoryview min next object oct open ord pow | 
					
						
							|  |  |  |   syn keyword pythonBuiltin	print property range repr reversed round set | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |   syn keyword pythonBuiltin	setattr slice sorted staticmethod str | 
					
						
							|  |  |  |   syn keyword pythonBuiltin	sum super tuple type vars zip __import__ | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  |   " Python 2 only | 
					
						
							|  |  |  |   syn keyword pythonBuiltin	basestring cmp execfile file | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |   syn keyword pythonBuiltin	long raw_input reduce reload unichr | 
					
						
							|  |  |  |   syn keyword pythonBuiltin	unicode xrange | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  |   " Python 3 only | 
					
						
							|  |  |  |   syn keyword pythonBuiltin	ascii bytes exec | 
					
						
							|  |  |  |   " non-essential built-in functions; Python 2 only | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |   syn keyword pythonBuiltin	apply buffer coerce intern | 
					
						
							| 
									
										
										
										
											2016-03-12 12:57:59 +01:00
										 |  |  |   " avoid highlighting attributes as builtins | 
					
						
							| 
									
										
										
										
											2016-10-30 21:55:26 +01:00
										 |  |  |   syn match   pythonAttribute	/\.\h\w*/hs=s+1 | 
					
						
							|  |  |  | 	\ contains=ALLBUT,pythonBuiltin,pythonFunction,pythonAsync | 
					
						
							|  |  |  | 	\ transparent | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | " From the 'Python Library Reference' class hierarchy at the bottom. | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  | " http://docs.python.org/2/library/exceptions.html | 
					
						
							|  |  |  | " http://docs.python.org/3/library/exceptions.html | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | if !exists("python_no_exception_highlight") | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  |   " builtin base exceptions (used mostly as base classes for other exceptions) | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |   syn keyword pythonExceptions	BaseException Exception | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  |   syn keyword pythonExceptions	ArithmeticError BufferError | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |   syn keyword pythonExceptions	LookupError | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  |   " builtin base exceptions removed in Python 3 | 
					
						
							|  |  |  |   syn keyword pythonExceptions	EnvironmentError StandardError | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |   " builtin exceptions (actually raised) | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  |   syn keyword pythonExceptions	AssertionError AttributeError | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |   syn keyword pythonExceptions	EOFError FloatingPointError GeneratorExit | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  |   syn keyword pythonExceptions	ImportError IndentationError | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |   syn keyword pythonExceptions	IndexError KeyError KeyboardInterrupt | 
					
						
							|  |  |  |   syn keyword pythonExceptions	MemoryError NameError NotImplementedError | 
					
						
							|  |  |  |   syn keyword pythonExceptions	OSError OverflowError ReferenceError | 
					
						
							|  |  |  |   syn keyword pythonExceptions	RuntimeError StopIteration SyntaxError | 
					
						
							|  |  |  |   syn keyword pythonExceptions	SystemError SystemExit TabError TypeError | 
					
						
							|  |  |  |   syn keyword pythonExceptions	UnboundLocalError UnicodeError | 
					
						
							|  |  |  |   syn keyword pythonExceptions	UnicodeDecodeError UnicodeEncodeError | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  |   syn keyword pythonExceptions	UnicodeTranslateError ValueError | 
					
						
							|  |  |  |   syn keyword pythonExceptions	ZeroDivisionError | 
					
						
							|  |  |  |   " builtin OS exceptions in Python 3 | 
					
						
							|  |  |  |   syn keyword pythonExceptions	BlockingIOError BrokenPipeError | 
					
						
							|  |  |  |   syn keyword pythonExceptions	ChildProcessError ConnectionAbortedError | 
					
						
							|  |  |  |   syn keyword pythonExceptions	ConnectionError ConnectionRefusedError | 
					
						
							|  |  |  |   syn keyword pythonExceptions	ConnectionResetError FileExistsError | 
					
						
							|  |  |  |   syn keyword pythonExceptions	FileNotFoundError InterruptedError | 
					
						
							|  |  |  |   syn keyword pythonExceptions	IsADirectoryError NotADirectoryError | 
					
						
							|  |  |  |   syn keyword pythonExceptions	PermissionError ProcessLookupError | 
					
						
							| 
									
										
										
										
											2015-09-25 20:34:21 +02:00
										 |  |  |   syn keyword pythonExceptions	RecursionError StopAsyncIteration | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  |   syn keyword pythonExceptions	TimeoutError | 
					
						
							|  |  |  |   " builtin exceptions deprecated/removed in Python 3 | 
					
						
							|  |  |  |   syn keyword pythonExceptions	IOError VMSError WindowsError | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |   " builtin warnings | 
					
						
							|  |  |  |   syn keyword pythonExceptions	BytesWarning DeprecationWarning FutureWarning | 
					
						
							|  |  |  |   syn keyword pythonExceptions	ImportWarning PendingDeprecationWarning | 
					
						
							|  |  |  |   syn keyword pythonExceptions	RuntimeWarning SyntaxWarning UnicodeWarning | 
					
						
							|  |  |  |   syn keyword pythonExceptions	UserWarning Warning | 
					
						
							| 
									
										
										
										
											2015-07-21 19:19:13 +02:00
										 |  |  |   " builtin warnings in Python 3 | 
					
						
							|  |  |  |   syn keyword pythonExceptions	ResourceWarning | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | if exists("python_space_error_highlight") | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |   " trailing whitespace | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |   syn match   pythonSpaceError	display excludenl "\s\+$" | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |   " mixed tabs and spaces | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |   syn match   pythonSpaceError	display " \+\t" | 
					
						
							|  |  |  |   syn match   pythonSpaceError	display "\t\+ " | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | " Do not spell doctests inside strings. | 
					
						
							|  |  |  | " Notice that the end of a string, either ''', or """, will end the contained | 
					
						
							|  |  |  | " doctest too.  Thus, we do *not* need to have it as an end pattern. | 
					
						
							|  |  |  | if !exists("python_no_doctest_highlight") | 
					
						
							| 
									
										
										
										
											2013-03-07 13:20:54 +01:00
										 |  |  |   if !exists("python_no_doctest_code_highlight") | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |     syn region pythonDoctest | 
					
						
							|  |  |  | 	  \ start="^\s*>>>\s" end="^\s*$" | 
					
						
							| 
									
										
										
										
											2016-10-30 21:55:26 +01:00
										 |  |  | 	  \ contained contains=ALLBUT,pythonDoctest,pythonFunction,@Spell | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  |     syn region pythonDoctestValue | 
					
						
							|  |  |  | 	  \ start=+^\s*\%(>>>\s\|\.\.\.\s\|"""\|'''\)\@!\S\++ end="$" | 
					
						
							|  |  |  | 	  \ contained | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     syn region pythonDoctest | 
					
						
							|  |  |  | 	  \ start="^\s*>>>" end="^\s*$" | 
					
						
							|  |  |  | 	  \ contained contains=@NoSpell | 
					
						
							|  |  |  |   endif | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Sync at the beginning of class, function, or method definition. | 
					
						
							| 
									
										
										
										
											2016-10-30 21:55:26 +01:00
										 |  |  | syn sync match pythonSync grouphere NONE "^\%(def\|class\)\s\+\h\w*\s*[(:]" | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | " The default highlight links.  Can be overridden later. | 
					
						
							| 
									
										
										
										
											2016-09-16 20:02:31 +02:00
										 |  |  | hi def link pythonStatement		Statement | 
					
						
							|  |  |  | hi def link pythonConditional		Conditional | 
					
						
							| 
									
										
										
										
											2016-08-31 22:22:10 +02:00
										 |  |  | hi def link pythonRepeat		Repeat | 
					
						
							|  |  |  | hi def link pythonOperator		Operator | 
					
						
							| 
									
										
										
										
											2016-09-16 20:02:31 +02:00
										 |  |  | hi def link pythonException		Exception | 
					
						
							| 
									
										
										
										
											2016-08-31 22:22:10 +02:00
										 |  |  | hi def link pythonInclude		Include | 
					
						
							| 
									
										
										
										
											2016-09-16 20:02:31 +02:00
										 |  |  | hi def link pythonAsync			Statement | 
					
						
							|  |  |  | hi def link pythonDecorator		Define | 
					
						
							|  |  |  | hi def link pythonDecoratorName		Function | 
					
						
							| 
									
										
										
										
											2016-08-31 22:22:10 +02:00
										 |  |  | hi def link pythonFunction		Function | 
					
						
							|  |  |  | hi def link pythonComment		Comment | 
					
						
							| 
									
										
										
										
											2016-09-16 20:02:31 +02:00
										 |  |  | hi def link pythonTodo			Todo | 
					
						
							| 
									
										
										
										
											2016-08-31 22:22:10 +02:00
										 |  |  | hi def link pythonString		String | 
					
						
							| 
									
										
										
										
											2016-09-16 20:02:31 +02:00
										 |  |  | hi def link pythonRawString		String | 
					
						
							| 
									
										
										
										
											2016-08-31 22:22:10 +02:00
										 |  |  | hi def link pythonQuotes		String | 
					
						
							| 
									
										
										
										
											2016-09-16 20:02:31 +02:00
										 |  |  | hi def link pythonTripleQuotes		pythonQuotes | 
					
						
							| 
									
										
										
										
											2016-08-31 22:22:10 +02:00
										 |  |  | hi def link pythonEscape		Special | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | if !exists("python_no_number_highlight") | 
					
						
							| 
									
										
										
										
											2016-08-31 22:22:10 +02:00
										 |  |  |   hi def link pythonNumber		Number | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | endif | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | if !exists("python_no_builtin_highlight") | 
					
						
							| 
									
										
										
										
											2016-09-16 20:02:31 +02:00
										 |  |  |   hi def link pythonBuiltin		Function | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | endif | 
					
						
							|  |  |  | if !exists("python_no_exception_highlight") | 
					
						
							| 
									
										
										
										
											2016-09-16 20:02:31 +02:00
										 |  |  |   hi def link pythonExceptions		Structure | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | endif | 
					
						
							|  |  |  | if exists("python_space_error_highlight") | 
					
						
							| 
									
										
										
										
											2016-09-16 20:02:31 +02:00
										 |  |  |   hi def link pythonSpaceError		Error | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | endif | 
					
						
							|  |  |  | if !exists("python_no_doctest_highlight") | 
					
						
							| 
									
										
										
										
											2016-09-16 20:02:31 +02:00
										 |  |  |   hi def link pythonDoctest		Special | 
					
						
							| 
									
										
										
										
											2016-08-31 22:22:10 +02:00
										 |  |  |   hi def link pythonDoctestValue	Define | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | let b:current_syntax = "python" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-21 22:34:02 +02:00
										 |  |  | let &cpo = s:cpo_save | 
					
						
							|  |  |  | unlet s:cpo_save | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-06 20:54:52 +01:00
										 |  |  | " vim:set sw=2 sts=2 ts=8 noet: |