Mercurial > vim
comparison runtime/syntax/python.vim @ 24024:ef454a7f485d
Update runtime files.
Commit: https://github.com/vim/vim/commit/9faec4e3d439968e21ad74e917aebb289df8f849
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 27 16:38:07 2021 +0100
Update runtime files.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 27 Feb 2021 16:45:04 +0100 |
parents | 169a62d5bcb9 |
children | 3a63b1e4a6f4 |
comparison
equal
deleted
inserted
replaced
24023:9b4821b59aa8 | 24024:ef454a7f485d |
---|---|
1 " Vim syntax file | 1 " Vim syntax file |
2 " Language: Python | 2 " Language: Python |
3 " Maintainer: Zvezdan Petkovic <zpetkovic@acm.org> | 3 " Maintainer: Zvezdan Petkovic <zpetkovic@acm.org> |
4 " Last Change: 2016 Oct 29 | 4 " Last Change: 2021 Feb 15 |
5 " Credits: Neil Schemenauer <nas@python.ca> | 5 " Credits: Neil Schemenauer <nas@python.ca> |
6 " Dmitry Vasiliev | 6 " Dmitry Vasiliev |
7 " | 7 " |
8 " This version is a major rewrite by Zvezdan Petkovic. | 8 " This version is a major rewrite by Zvezdan Petkovic. |
9 " | 9 " |
69 let python_space_error_highlight = 1 | 69 let python_space_error_highlight = 1 |
70 endif | 70 endif |
71 | 71 |
72 " Keep Python keywords in alphabetical order inside groups for easy | 72 " Keep Python keywords in alphabetical order inside groups for easy |
73 " comparison with the table in the 'Python Language Reference' | 73 " comparison with the table in the 'Python Language Reference' |
74 " https://docs.python.org/2/reference/lexical_analysis.html#keywords, | 74 " https://docs.python.org/reference/lexical_analysis.html#keywords. |
75 " https://docs.python.org/3/reference/lexical_analysis.html#keywords. | |
76 " Groups are in the order presented in NAMING CONVENTIONS in syntax.txt. | 75 " Groups are in the order presented in NAMING CONVENTIONS in syntax.txt. |
77 " Exceptions come last at the end of each group (class and def below). | 76 " Exceptions come last at the end of each group (class and def below). |
78 " | 77 " |
79 " Keywords 'with' and 'as' are new in Python 2.6 | 78 " The list can be checked using: |
80 " (use 'from __future__ import with_statement' in Python 2.5). | 79 " |
81 " | 80 " python3 -c 'import keyword, pprint; pprint.pprint(keyword.kwlist, compact=True)' |
82 " Some compromises had to be made to support both Python 3 and 2. | |
83 " We include Python 3 features, but when a definition is duplicated, | |
84 " the last definition takes precedence. | |
85 " | |
86 " - 'False', 'None', and 'True' are keywords in Python 3 but they are | |
87 " built-ins in 2 and will be highlighted as built-ins below. | |
88 " - 'exec' is a built-in in Python 3 and will be highlighted as | |
89 " built-in below. | |
90 " - 'nonlocal' is a keyword in Python 3 and will be highlighted. | |
91 " - 'print' is a built-in in Python 3 and will be highlighted as | |
92 " built-in below (use 'from __future__ import print_function' in 2) | |
93 " - async and await were added in Python 3.5 and are soft keywords. | |
94 " | 81 " |
95 syn keyword pythonStatement False None True | 82 syn keyword pythonStatement False None True |
96 syn keyword pythonStatement as assert break continue del exec global | 83 syn keyword pythonStatement as assert break continue del global |
97 syn keyword pythonStatement lambda nonlocal pass print return with yield | 84 syn keyword pythonStatement lambda nonlocal pass return with yield |
98 syn keyword pythonStatement class def nextgroup=pythonFunction skipwhite | 85 syn keyword pythonStatement class def nextgroup=pythonFunction skipwhite |
99 syn keyword pythonConditional elif else if | 86 syn keyword pythonConditional elif else if |
100 syn keyword pythonRepeat for while | 87 syn keyword pythonRepeat for while |
101 syn keyword pythonOperator and in is not or | 88 syn keyword pythonOperator and in is not or |
102 syn keyword pythonException except finally raise try | 89 syn keyword pythonException except finally raise try |
103 syn keyword pythonInclude from import | 90 syn keyword pythonInclude from import |
104 syn keyword pythonAsync async await | 91 syn keyword pythonAsync async await |
105 | 92 |
106 " Decorators (new in Python 2.4) | 93 " Decorators |
107 " A dot must be allowed because of @MyClass.myfunc decorators. | 94 " A dot must be allowed because of @MyClass.myfunc decorators. |
108 syn match pythonDecorator "@" display contained | 95 syn match pythonDecorator "@" display contained |
109 syn match pythonDecoratorName "@\s*\h\%(\w\|\.\)*" display contains=pythonDecorator | 96 syn match pythonDecoratorName "@\s*\h\%(\w\|\.\)*" display contains=pythonDecorator |
110 | 97 |
111 " Python 3.5 introduced the use of the same symbol for matrix multiplication: | 98 " Python 3.5 introduced the use of the same symbol for matrix multiplication: |
166 " - a second dot in 1.0.0 is not highlighted, | 153 " - a second dot in 1.0.0 is not highlighted, |
167 " - 08 is not highlighted, | 154 " - 08 is not highlighted, |
168 " - 08e0 or 08j are highlighted, | 155 " - 08e0 or 08j are highlighted, |
169 " | 156 " |
170 " and so on, as specified in the 'Python Language Reference'. | 157 " and so on, as specified in the 'Python Language Reference'. |
171 " https://docs.python.org/2/reference/lexical_analysis.html#numeric-literals | 158 " https://docs.python.org/reference/lexical_analysis.html#numeric-literals |
172 " https://docs.python.org/3/reference/lexical_analysis.html#numeric-literals | |
173 if !exists("python_no_number_highlight") | 159 if !exists("python_no_number_highlight") |
174 " numbers (including longs and complex) | 160 " numbers (including longs and complex) |
175 syn match pythonNumber "\<0[oO]\=\o\+[Ll]\=\>" | 161 syn match pythonNumber "\<0[oO]\=\o\+[Ll]\=\>" |
176 syn match pythonNumber "\<0[xX]\x\+[Ll]\=\>" | 162 syn match pythonNumber "\<0[xX]\x\+[Ll]\=\>" |
177 syn match pythonNumber "\<0[bB][01]\+[Ll]\=\>" | 163 syn match pythonNumber "\<0[bB][01]\+[Ll]\=\>" |
184 \ "\%(^\|\W\)\zs\d*\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>" | 170 \ "\%(^\|\W\)\zs\d*\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>" |
185 endif | 171 endif |
186 | 172 |
187 " Group the built-ins in the order in the 'Python Library Reference' for | 173 " Group the built-ins in the order in the 'Python Library Reference' for |
188 " easier comparison. | 174 " easier comparison. |
189 " https://docs.python.org/2/library/constants.html | 175 " https://docs.python.org/library/constants.html |
190 " https://docs.python.org/3/library/constants.html | 176 " http://docs.python.org/library/functions.html |
191 " http://docs.python.org/2/library/functions.html | |
192 " http://docs.python.org/3/library/functions.html | |
193 " http://docs.python.org/2/library/functions.html#non-essential-built-in-functions | |
194 " http://docs.python.org/3/library/functions.html#non-essential-built-in-functions | |
195 " Python built-in functions are in alphabetical order. | 177 " Python built-in functions are in alphabetical order. |
178 " | |
179 " The list can be checked using: | |
180 " | |
181 " python3 -c 'import builtins, pprint; pprint.pprint(dir(builtins), compact=True)' | |
182 " | |
183 " The constants added by the `site` module are not listed below because they | |
184 " should not be used in programs, only in interactive interpreter. | |
185 " Similarly for some other attributes and functions `__`-enclosed from the | |
186 " output of the above command. | |
187 " | |
196 if !exists("python_no_builtin_highlight") | 188 if !exists("python_no_builtin_highlight") |
197 " built-in constants | 189 " built-in constants |
198 " 'False', 'True', and 'None' are also reserved words in Python 3 | 190 " 'False', 'True', and 'None' are also reserved words in Python 3 |
199 syn keyword pythonBuiltin False True None | 191 syn keyword pythonBuiltin False True None |
200 syn keyword pythonBuiltin NotImplemented Ellipsis __debug__ | 192 syn keyword pythonBuiltin NotImplemented Ellipsis __debug__ |
193 " constants added by the `site` module | |
194 syn keyword pythonBuiltin quit exit copyright credits license | |
201 " built-in functions | 195 " built-in functions |
202 syn keyword pythonBuiltin abs all any bin bool bytearray callable chr | 196 syn keyword pythonBuiltin abs all any ascii bin bool breakpoint bytearray |
203 syn keyword pythonBuiltin classmethod compile complex delattr dict dir | 197 syn keyword pythonBuiltin bytes callable chr classmethod compile complex |
204 syn keyword pythonBuiltin divmod enumerate eval filter float format | 198 syn keyword pythonBuiltin delattr dict dir divmod enumerate eval exec |
205 syn keyword pythonBuiltin frozenset getattr globals hasattr hash | 199 syn keyword pythonBuiltin filter float format frozenset getattr globals |
206 syn keyword pythonBuiltin help hex id input int isinstance | 200 syn keyword pythonBuiltin hasattr hash help hex id input int isinstance |
207 syn keyword pythonBuiltin issubclass iter len list locals map max | 201 syn keyword pythonBuiltin issubclass iter len list locals map max |
208 syn keyword pythonBuiltin memoryview min next object oct open ord pow | 202 syn keyword pythonBuiltin memoryview min next object oct open ord pow |
209 syn keyword pythonBuiltin print property range repr reversed round set | 203 syn keyword pythonBuiltin print property range repr reversed round set |
210 syn keyword pythonBuiltin setattr slice sorted staticmethod str | 204 syn keyword pythonBuiltin setattr slice sorted staticmethod str sum super |
211 syn keyword pythonBuiltin sum super tuple type vars zip __import__ | 205 syn keyword pythonBuiltin tuple type vars zip __import__ |
212 " Python 2 only | |
213 syn keyword pythonBuiltin basestring cmp execfile file | |
214 syn keyword pythonBuiltin long raw_input reduce reload unichr | |
215 syn keyword pythonBuiltin unicode xrange | |
216 " Python 3 only | |
217 syn keyword pythonBuiltin ascii bytes exec | |
218 " non-essential built-in functions; Python 2 only | |
219 syn keyword pythonBuiltin apply buffer coerce intern | |
220 " avoid highlighting attributes as builtins | 206 " avoid highlighting attributes as builtins |
221 syn match pythonAttribute /\.\h\w*/hs=s+1 | 207 syn match pythonAttribute /\.\h\w*/hs=s+1 |
222 \ contains=ALLBUT,pythonBuiltin,pythonFunction,pythonAsync | 208 \ contains=ALLBUT,pythonBuiltin,pythonFunction,pythonAsync |
223 \ transparent | 209 \ transparent |
224 endif | 210 endif |
225 | 211 |
226 " From the 'Python Library Reference' class hierarchy at the bottom. | 212 " From the 'Python Library Reference' class hierarchy at the bottom. |
227 " http://docs.python.org/2/library/exceptions.html | 213 " http://docs.python.org/library/exceptions.html |
228 " http://docs.python.org/3/library/exceptions.html | |
229 if !exists("python_no_exception_highlight") | 214 if !exists("python_no_exception_highlight") |
230 " builtin base exceptions (used mostly as base classes for other exceptions) | 215 " builtin base exceptions (used mostly as base classes for other exceptions) |
231 syn keyword pythonExceptions BaseException Exception | 216 syn keyword pythonExceptions BaseException Exception |
232 syn keyword pythonExceptions ArithmeticError BufferError | 217 syn keyword pythonExceptions ArithmeticError BufferError LookupError |
233 syn keyword pythonExceptions LookupError | |
234 " builtin base exceptions removed in Python 3 | |
235 syn keyword pythonExceptions EnvironmentError StandardError | |
236 " builtin exceptions (actually raised) | 218 " builtin exceptions (actually raised) |
237 syn keyword pythonExceptions AssertionError AttributeError | 219 syn keyword pythonExceptions AssertionError AttributeError EOFError |
238 syn keyword pythonExceptions EOFError FloatingPointError GeneratorExit | 220 syn keyword pythonExceptions FloatingPointError GeneratorExit ImportError |
239 syn keyword pythonExceptions ImportError IndentationError | 221 syn keyword pythonExceptions IndentationError IndexError KeyError |
240 syn keyword pythonExceptions IndexError KeyError KeyboardInterrupt | 222 syn keyword pythonExceptions KeyboardInterrupt MemoryError |
241 syn keyword pythonExceptions MemoryError NameError NotImplementedError | 223 syn keyword pythonExceptions ModuleNotFoundError NameError |
242 syn keyword pythonExceptions OSError OverflowError ReferenceError | 224 syn keyword pythonExceptions NotImplementedError OSError OverflowError |
243 syn keyword pythonExceptions RuntimeError StopIteration SyntaxError | 225 syn keyword pythonExceptions RecursionError ReferenceError RuntimeError |
226 syn keyword pythonExceptions StopAsyncIteration StopIteration SyntaxError | |
244 syn keyword pythonExceptions SystemError SystemExit TabError TypeError | 227 syn keyword pythonExceptions SystemError SystemExit TabError TypeError |
245 syn keyword pythonExceptions UnboundLocalError UnicodeError | 228 syn keyword pythonExceptions UnboundLocalError UnicodeDecodeError |
246 syn keyword pythonExceptions UnicodeDecodeError UnicodeEncodeError | 229 syn keyword pythonExceptions UnicodeEncodeError UnicodeError |
247 syn keyword pythonExceptions UnicodeTranslateError ValueError | 230 syn keyword pythonExceptions UnicodeTranslateError ValueError |
248 syn keyword pythonExceptions ZeroDivisionError | 231 syn keyword pythonExceptions ZeroDivisionError |
232 " builtin exception aliases for OSError | |
233 syn keyword pythonExceptions EnvironmentError IOError WindowsError | |
249 " builtin OS exceptions in Python 3 | 234 " builtin OS exceptions in Python 3 |
250 syn keyword pythonExceptions BlockingIOError BrokenPipeError | 235 syn keyword pythonExceptions BlockingIOError BrokenPipeError |
251 syn keyword pythonExceptions ChildProcessError ConnectionAbortedError | 236 syn keyword pythonExceptions ChildProcessError ConnectionAbortedError |
252 syn keyword pythonExceptions ConnectionError ConnectionRefusedError | 237 syn keyword pythonExceptions ConnectionError ConnectionRefusedError |
253 syn keyword pythonExceptions ConnectionResetError FileExistsError | 238 syn keyword pythonExceptions ConnectionResetError FileExistsError |
254 syn keyword pythonExceptions FileNotFoundError InterruptedError | 239 syn keyword pythonExceptions FileNotFoundError InterruptedError |
255 syn keyword pythonExceptions IsADirectoryError NotADirectoryError | 240 syn keyword pythonExceptions IsADirectoryError NotADirectoryError |
256 syn keyword pythonExceptions PermissionError ProcessLookupError | 241 syn keyword pythonExceptions PermissionError ProcessLookupError TimeoutError |
257 syn keyword pythonExceptions RecursionError StopAsyncIteration | |
258 syn keyword pythonExceptions TimeoutError | |
259 " builtin exceptions deprecated/removed in Python 3 | |
260 syn keyword pythonExceptions IOError VMSError WindowsError | |
261 " builtin warnings | 242 " builtin warnings |
262 syn keyword pythonExceptions BytesWarning DeprecationWarning FutureWarning | 243 syn keyword pythonExceptions BytesWarning DeprecationWarning FutureWarning |
263 syn keyword pythonExceptions ImportWarning PendingDeprecationWarning | 244 syn keyword pythonExceptions ImportWarning PendingDeprecationWarning |
264 syn keyword pythonExceptions RuntimeWarning SyntaxWarning UnicodeWarning | 245 syn keyword pythonExceptions ResourceWarning RuntimeWarning |
246 syn keyword pythonExceptions SyntaxWarning UnicodeWarning | |
265 syn keyword pythonExceptions UserWarning Warning | 247 syn keyword pythonExceptions UserWarning Warning |
266 " builtin warnings in Python 3 | |
267 syn keyword pythonExceptions ResourceWarning | |
268 endif | 248 endif |
269 | 249 |
270 if exists("python_space_error_highlight") | 250 if exists("python_space_error_highlight") |
271 " trailing whitespace | 251 " trailing whitespace |
272 syn match pythonSpaceError display excludenl "\s\+$" | 252 syn match pythonSpaceError display excludenl "\s\+$" |