annotate runtime/syntax/python.vim @ 2034:7bc41231fbc7

Update runtime files.
author Bram Moolenaar <bram@zimbu.org>
date Wed, 06 Jan 2010 20:54:52 +0100
parents 96cd8222a819
children d0049ff5969e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim syntax file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: Python
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Maintainer: Neil Schemenauer <nas@python.ca>
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
4 " Last Change: 2009-10-13
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
5 " Credits: Zvezdan Petkovic <zpetkovic@acm.org>
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
6 " Neil Schemenauer <nas@python.ca>
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
7 " Dmitry Vasiliev
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 "
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
9 " This version is a major rewrite by Zvezdan Petkovic.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 "
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
11 " - introduced highlighting of doctests
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
12 " - updated keywords, built-ins, and exceptions
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
13 " - corrected regular expressions for
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 "
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
15 " * functions
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
16 " * decorators
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
17 " * strings
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
18 " * escapes
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
19 " * numbers
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
20 " * space error
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 "
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
22 " - corrected synchronization
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
23 " - more highlighting is ON by default, except
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
24 " - space error highlighting is OFF by default
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 "
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
26 " Optional highlighting can be controlled using these variables.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 "
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
28 " let python_no_builtin_highlight = 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
29 " let python_no_doctest_code_highlight = 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
30 " let python_no_doctest_highlight = 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
31 " let python_no_exception_highlight = 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
32 " let python_no_number_highlight = 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
33 " let python_space_error_highlight = 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 "
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
35 " All the options above can be switched on together.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
36 "
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
37 " let python_highlight_all = 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
40 " For version 5.x: Clear all syntax items.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
41 " For version 6.x: Quit when a syntax file was already loaded.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 if version < 600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 syntax clear
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 elseif exists("b:current_syntax")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
48 " Keep Python keywords in alphabetical order inside groups for easy
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
49 " comparison with the table in the 'Python Language Reference'
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
50 " http://docs.python.org/reference/lexical_analysis.html#keywords.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
51 " Groups are in the order presented in NAMING CONVENTIONS in syntax.txt.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
52 " Exceptions come last at the end of each group (class and def below).
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
53 "
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
54 " Keywords 'with' and 'as' are new in Python 2.6
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
55 " (use 'from __future__ import with_statement' in Python 2.5).
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
56 "
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
57 " Some compromises had to be made to support both Python 3.0 and 2.6.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
58 " We include Python 3.0 features, but when a definition is duplicated,
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
59 " the last definition takes precedence.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
60 "
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
61 " - 'False', 'None', and 'True' are keywords in Python 3.0 but they are
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
62 " built-ins in 2.6 and will be highlighted as built-ins below.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
63 " - 'exec' is a built-in in Python 3.0 and will be highlighted as
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
64 " built-in below.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
65 " - 'nonlocal' is a keyword in Python 3.0 and will be highlighted.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
66 " - 'print' is a built-in in Python 3.0 and will be highlighted as
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
67 " built-in below (use 'from __future__ import print_function' in 2.6)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
68 "
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
69 syn keyword pythonStatement False, None, True
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
70 syn keyword pythonStatement as assert break continue del exec global
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
71 syn keyword pythonStatement lambda nonlocal pass print return with yield
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
72 syn keyword pythonStatement class def nextgroup=pythonFunction skipwhite
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
73 syn keyword pythonConditional elif else if
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 syn keyword pythonRepeat for while
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 syn keyword pythonOperator and in is not or
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
76 syn keyword pythonException except finally raise try
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
77 syn keyword pythonInclude from import
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 818
diff changeset
79 " Decorators (new in Python 2.4)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 818
diff changeset
80 syn match pythonDecorator "@" display nextgroup=pythonFunction skipwhite
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
81 " The zero-length non-grouping match before the function name is
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
82 " extremely important in pythonFunction. Without it, everything is
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
83 " interpreted as a function inside the contained environment of
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
84 " doctests.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
85 " A dot must be allowed because of @MyClass.myfunc decorators.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
86 syn match pythonFunction
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
87 \ "\%(\%(def\s\|class\s\|@\)\s*\)\@<=\h\%(\w\|\.\)*" contained
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 818
diff changeset
88
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
89 syn match pythonComment "#.*$" contains=pythonTodo,@Spell
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
90 syn keyword pythonTodo FIXME NOTE NOTES TODO XXX contained
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
91
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
92 " Triple-quoted strings can contain doctests.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
93 syn region pythonString
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
94 \ start=+[uU]\=\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
95 \ contains=pythonEscape,@Spell
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
96 syn region pythonString
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
97 \ start=+[uU]\=\z('''\|"""\)+ end="\z1" keepend
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
98 \ contains=pythonEscape,pythonSpaceError,pythonDoctest,@Spell
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
99 syn region pythonRawString
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
100 \ start=+[uU]\=[rR]\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
101 \ contains=@Spell
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
102 syn region pythonRawString
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
103 \ start=+[uU]\=[rR]\z('''\|"""\)+ end="\z1" keepend
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
104 \ contains=pythonSpaceError,pythonDoctest,@Spell
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
105
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
106 syn match pythonEscape +\\[abfnrtv'"\\]+ contained
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
107 syn match pythonEscape "\\\o\{1,3}" contained
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
108 syn match pythonEscape "\\x\x\{2}" contained
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
109 syn match pythonEscape "\%(\\u\x\{4}\|\\U\x\{8}\)" contained
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
110 " Python allows case-insensitive Unicode IDs: http://www.unicode.org/charts/
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
111 syn match pythonEscape "\\N{\a\+\%(\s\a\+\)*}" contained
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
112 syn match pythonEscape "\\$"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 if exists("python_highlight_all")
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
115 if exists("python_no_builtin_highlight")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
116 unlet python_no_builtin_highlight
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
117 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
118 if exists("python_no_doctest_code_highlight")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
119 unlet python_no_doctest_code_highlight
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
120 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
121 if exists("python_no_doctest_highlight")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
122 unlet python_no_doctest_highlight
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
123 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
124 if exists("python_no_exception_highlight")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
125 unlet python_no_exception_highlight
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
126 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
127 if exists("python_no_number_highlight")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
128 unlet python_no_number_highlight
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
129 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
130 let python_space_error_highlight = 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
133 " It is very important to understand all details before changing the
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
134 " regular expressions below or their order.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
135 " The word boundaries are *not* the floating-point number boundaries
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
136 " because of a possible leading or trailing decimal point.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
137 " The expressions below ensure that all valid number literals are
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
138 " highlighted, and invalid number literals are not. For example,
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
139 "
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
140 " - a decimal point in '4.' at the end of a line is highlighted,
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
141 " - a second dot in 1.0.0 is not highlighted,
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
142 " - 08 is not highlighted,
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
143 " - 08e0 or 08j are highlighted,
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
144 "
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
145 " and so on, as specified in the 'Python Language Reference'.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
146 " http://docs.python.org/reference/lexical_analysis.html#numeric-literals
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
147 if !exists("python_no_number_highlight")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 " numbers (including longs and complex)
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
149 syn match pythonNumber "\<0[oO]\=\o\+[Ll]\=\>"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
150 syn match pythonNumber "\<0[xX]\x\+[Ll]\=\>"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
151 syn match pythonNumber "\<0[bB][01]\+[Ll]\=\>"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
152 syn match pythonNumber "\<\%([1-9]\d*\|0\)[Ll]\=\>"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
153 syn match pythonNumber "\<\d\+[jJ]\>"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
154 syn match pythonNumber "\<\d\+[eE][+-]\=\d\+[jJ]\=\>"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
155 syn match pythonNumber
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
156 \ "\<\d\+\.\%([eE][+-]\=\d\+\)\=[jJ]\=\%(\W\|$\)\@="
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
157 syn match pythonNumber
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
158 \ "\%(^\|\W\)\@<=\d*\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
161 " Group the built-ins in the order in the 'Python Library Reference' for
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
162 " easier comparison.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
163 " http://docs.python.org/library/constants.html
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
164 " http://docs.python.org/library/functions.html
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
165 " http://docs.python.org/library/functions.html#non-essential-built-in-functions
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
166 " Python built-in functions are in alphabetical order.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
167 if !exists("python_no_builtin_highlight")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
168 " built-in constants
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
169 " 'False', 'True', and 'None' are also reserved words in Python 3.0
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
170 syn keyword pythonBuiltin False True None
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
171 syn keyword pythonBuiltin NotImplemented Ellipsis __debug__
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
172 " built-in functions
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
173 syn keyword pythonBuiltin abs all any bin bool chr classmethod
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
174 syn keyword pythonBuiltin compile complex delattr dict dir divmod
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
175 syn keyword pythonBuiltin enumerate eval filter float format
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
176 syn keyword pythonBuiltin frozenset getattr globals hasattr hash
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
177 syn keyword pythonBuiltin help hex id input int isinstance
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
178 syn keyword pythonBuiltin issubclass iter len list locals map max
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
179 syn keyword pythonBuiltin min next object oct open ord pow print
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
180 syn keyword pythonBuiltin property range repr reversed round set
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
181 syn keyword pythonBuiltin setattr slice sorted staticmethod str
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
182 syn keyword pythonBuiltin sum super tuple type vars zip __import__
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
183 " Python 2.6 only
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
184 syn keyword pythonBuiltin basestring callable cmp execfile file
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
185 syn keyword pythonBuiltin long raw_input reduce reload unichr
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
186 syn keyword pythonBuiltin unicode xrange
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
187 " Python 3.0 only
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
188 syn keyword pythonBuiltin ascii bytearray bytes exec memoryview
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
189 " non-essential built-in functions; Python 2.6 only
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
190 syn keyword pythonBuiltin apply buffer coerce intern
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
193 " From the 'Python Library Reference' class hierarchy at the bottom.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
194 " http://docs.python.org/library/exceptions.html
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
195 if !exists("python_no_exception_highlight")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
196 " builtin base exceptions (only used as base classes for other exceptions)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
197 syn keyword pythonExceptions BaseException Exception
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
198 syn keyword pythonExceptions ArithmeticError EnvironmentError
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
199 syn keyword pythonExceptions LookupError
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
200 " builtin base exception removed in Python 3.0
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
201 syn keyword pythonExceptions StandardError
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
202 " builtin exceptions (actually raised)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
203 syn keyword pythonExceptions AssertionError AttributeError BufferError
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
204 syn keyword pythonExceptions EOFError FloatingPointError GeneratorExit
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
205 syn keyword pythonExceptions IOError ImportError IndentationError
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
206 syn keyword pythonExceptions IndexError KeyError KeyboardInterrupt
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
207 syn keyword pythonExceptions MemoryError NameError NotImplementedError
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
208 syn keyword pythonExceptions OSError OverflowError ReferenceError
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
209 syn keyword pythonExceptions RuntimeError StopIteration SyntaxError
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
210 syn keyword pythonExceptions SystemError SystemExit TabError TypeError
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
211 syn keyword pythonExceptions UnboundLocalError UnicodeError
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
212 syn keyword pythonExceptions UnicodeDecodeError UnicodeEncodeError
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
213 syn keyword pythonExceptions UnicodeTranslateError ValueError VMSError
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
214 syn keyword pythonExceptions WindowsError ZeroDivisionError
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
215 " builtin warnings
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
216 syn keyword pythonExceptions BytesWarning DeprecationWarning FutureWarning
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
217 syn keyword pythonExceptions ImportWarning PendingDeprecationWarning
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
218 syn keyword pythonExceptions RuntimeWarning SyntaxWarning UnicodeWarning
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
219 syn keyword pythonExceptions UserWarning Warning
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
222 if exists("python_space_error_highlight")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 " trailing whitespace
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
224 syn match pythonSpaceError display excludenl "\s\+$"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 " mixed tabs and spaces
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
226 syn match pythonSpaceError display " \+\t"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
227 syn match pythonSpaceError display "\t\+ "
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
230 " Do not spell doctests inside strings.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
231 " Notice that the end of a string, either ''', or """, will end the contained
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
232 " doctest too. Thus, we do *not* need to have it as an end pattern.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
233 if !exists("python_no_doctest_highlight")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
234 if !exists("python_no_doctest_code_higlight")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
235 syn region pythonDoctest
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
236 \ start="^\s*>>>\s" end="^\s*$"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
237 \ contained contains=ALLBUT,pythonDoctest,@Spell
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
238 syn region pythonDoctestValue
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
239 \ start=+^\s*\%(>>>\s\|\.\.\.\s\|"""\|'''\)\@!\S\++ end="$"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
240 \ contained
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
241 else
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
242 syn region pythonDoctest
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
243 \ start="^\s*>>>" end="^\s*$"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
244 \ contained contains=@NoSpell
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
245 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
246 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
247
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
248 " Sync at the beginning of class, function, or method definition.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
249 syn sync match pythonSync grouphere NONE "^\s*\%(def\|class\)\s\+\h\w*\s*("
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 if version >= 508 || !exists("did_python_syn_inits")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 if version <= 508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 let did_python_syn_inits = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 command -nargs=+ HiLink hi link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 command -nargs=+ HiLink hi def link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
259 " The default highlight links. Can be overridden later.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 HiLink pythonStatement Statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 HiLink pythonConditional Conditional
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 HiLink pythonRepeat Repeat
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
263 HiLink pythonOperator Operator
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
264 HiLink pythonException Exception
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
265 HiLink pythonInclude Include
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
266 HiLink pythonDecorator Define
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
267 HiLink pythonFunction Function
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
268 HiLink pythonComment Comment
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
269 HiLink pythonTodo Todo
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 HiLink pythonString String
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 HiLink pythonRawString String
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 HiLink pythonEscape Special
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
273 if !exists("python_no_number_highlight")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
274 HiLink pythonNumber Number
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 endif
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
276 if !exists("python_no_builtin_highlight")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 HiLink pythonBuiltin Function
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 endif
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
279 if !exists("python_no_exception_highlight")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
280 HiLink pythonExceptions Structure
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 endif
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
282 if exists("python_space_error_highlight")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 HiLink pythonSpaceError Error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 endif
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
285 if !exists("python_no_doctest_highlight")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
286 HiLink pythonDoctest Special
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
287 HiLink pythonDoctestValue Define
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
288 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 delcommand HiLink
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 let b:current_syntax = "python"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
295 " vim:set sw=2 sts=2 ts=8 noet: