├── .vintrc.yaml ├── AUTHORS ├── LICENSE ├── doc └── python-syntax.txt ├── README.md ├── tests └── test.py └── syntax └── python.vim /.vintrc.yaml: -------------------------------------------------------------------------------- 1 | policies: 2 | ProhibitImplicitScopeVariable: 3 | enabled: false 4 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the list of python-syntax authors for copyright purposes. 2 | # 3 | # This does not necessarily list everyone who has contributed code, since in 4 | # some cases, their employer may be the copyright holder. To see the full list 5 | # of contributors, see the revision history in source control. 6 | 7 | Andrea Riciputi 8 | Anton Butanaev 9 | Antony Lee 10 | Caleb Adamantine 11 | David Briscoe 12 | Dmitry Vasiliev 13 | Elizabeth Myers 14 | Ihor Gorobets 15 | Jeroen Ruigrok van der Werven 16 | John Eikenberry 17 | Joongi Kim 18 | lilydjwg 19 | Marc Weber 20 | Michael Doronin 21 | Neil Schemenauer 22 | nfnty 23 | Pedro Algarvio 24 | Victor Salgado 25 | Will Gray 26 | Yuri Habrusiev 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2002-2014 Dmitry Vasiliev 4 | Copyright (c) 2017- the python-syntax authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /doc/python-syntax.txt: -------------------------------------------------------------------------------- 1 | *python-syntax.txt* Python syntax highlighting 2 | 3 | ============================================================================== 4 | Introduction *python-syntax* *ft-python-syntax* *python.vim* 5 | 6 | This is an enhanced version of the original Vim 6.1 Python syntax highlighting 7 | `python.vim` by Neil Schemenauer. 8 | 9 | Features 10 | -------- 11 | 12 | * Enhanced highlighting for: 13 | * Strings 14 | * Special symbols inside strings 15 | * Numeric constants 16 | * Added support for: 17 | * Python 3 18 | * Numbers with underscores 19 | * String %-formatting and f-strings 20 | * Magic comments: source code encoding and shebangs 21 | * New exceptions and builtins 22 | * Doctests 23 | * `@decorator` syntax 24 | * Class variables such as `self`, `cls`, and `mcs` 25 | * Operators 26 | * Highlighting of the following errors: 27 | * Invalid symbols in source file 28 | * Invalid numeric constants 29 | * Invalid %-formatting inside strings 30 | * Invalid variable names 31 | * Invalid operators 32 | * Mixing spaces and tabs 33 | * Trailing spaces (Enabled with `g:python_highlight_space_errors`) 34 | * Commands for easy switching between versions 35 | 36 | Folding is done by the plugin SimpylFold 37 | (https://github.com/tmhedberg/SimpylFold). 38 | 39 | ============================================================================== 40 | Configuration *python-syntax-configuration* 41 | 42 | Option variables 43 | ---------------- 44 | 45 | Set variable to `1` to enable or `0` to disable. 46 | 47 | For example to enable all syntax highlighting features you can add the 48 | following command to your `~/.config/nvim/init.vim` or `~/.vimrc`: > 49 | 50 | let g:python_highlight_all = 1 51 | < 52 | 53 | `g:python_version_2` (default `0`) 54 | Python 2 mode 55 | 56 | `b:python_version_2` (default `0`) 57 | Python 2 mode (buffer local) 58 | 59 | `g:python_highlight_builtins` (default `0`) 60 | Highlight builtin objects, types, and functions 61 | 62 | `g:python_highlight_builtin_objs` (default `0`) 63 | Highlight builtin objects only 64 | 65 | `g:python_highlight_builtin_types` (default `0`) 66 | Highlight builtin types only 67 | 68 | `g:python_highlight_builtin_funcs` (default `0`) 69 | Highlight builtin functions only 70 | 71 | `g:python_highlight_builtin_funcs_kwarg` (default `1`) 72 | Highlight builtin functions when used as kwarg 73 | 74 | `g:python_highlight_exceptions` (default `0`) 75 | Highlight standard exceptions 76 | 77 | `g:python_highlight_string_formatting` (default `0`) 78 | Highlight `%` string formatting 79 | 80 | `g:python_highlight_string_format` (default `0`) 81 | Highlight syntax of `str.format` syntax 82 | 83 | `g:python_highlight_string_templates` (default `0`) 84 | Highlight syntax of `string.Template` 85 | 86 | `g:python_highlight_indent_errors` (default `0`) 87 | Highlight indentation errors 88 | 89 | `g:python_highlight_space_errors` (default `0`) 90 | Highlight trailing spaces 91 | 92 | `g:python_highlight_doctests` (default `0`) 93 | Highlight doc-tests 94 | 95 | `g:python_highlight_func_calls` (default `0`) 96 | Highlight functions calls 97 | 98 | `g:python_highlight_class_vars` (default `0`) 99 | Highlight class variables `self`, `cls`, and `mcs` 100 | 101 | `g:python_highlight_operators` (default `0`) 102 | Highlight all operators 103 | 104 | `g:python_highlight_all` (default `0`) 105 | Enable all highlight options above, except for previously set. 106 | 107 | `g:python_highlight_file_headers_as_comments` (default `0`) 108 | Highlight shebang and coding headers as comments 109 | 110 | `g:python_slow_sync` (default `1`) 111 | Disable for slow machines 112 | 113 | Commands 114 | -------- 115 | 116 | `Python2Syntax` 117 | Switch to Python 2 118 | 119 | `Python3Syntax` 120 | Switch to Python 3 121 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Python syntax highlighting for Vim 2 | ========================================= 3 | 4 | This is an enhanced version of the original Vim 6.1 Python syntax highlighting 5 | `python.vim` by Neil Schemenauer. 6 | 7 | Features 8 | -------- 9 | 10 | * Enhanced highlighting for: 11 | * Strings 12 | * Special symbols inside strings 13 | * Numeric constants 14 | * Added support for: 15 | * Python 3 16 | * Numbers with underscores 17 | * String %-formatting and f-strings 18 | * Magic comments: source code encoding and shebangs 19 | * New exceptions and builtins 20 | * Doctests 21 | * `@decorator` syntax 22 | * Class variables such as `self`, `cls`, and `mcs` 23 | * Operators 24 | * Highlighting of the following errors: 25 | * Invalid symbols in source file 26 | * Invalid numeric constants 27 | * Invalid %-formatting inside strings 28 | * Invalid variable names 29 | * Invalid operators 30 | * Mixing spaces and tabs 31 | * Trailing spaces (Enabled with `g:python_highlight_space_errors`) 32 | * Commands for easy switching between versions 33 | 34 | Folding is done by the plugin [SimpylFold](https://github.com/tmhedberg/SimpylFold). 35 | 36 | How to install 37 | -------------- 38 | 39 | Use one of the following plugin managers: 40 | 41 | * [dein](https://github.com/Shougo/dein.vim) 42 | * [vim-plug](https://github.com/junegunn/vim-plug) 43 | * [vundle](https://github.com/VundleVim/Vundle.vim) 44 | * [pathogen](https://github.com/tpope/vim-pathogen) 45 | 46 | Configuration 47 | ------------- 48 | 49 | ### Option variables 50 | 51 | Set variable to `1` to enable or `0` to disable. 52 | 53 | For example to enable all syntax highlighting features you can add the 54 | following command to your `~/.config/nvim/init.vim` or `~/.vimrc`: 55 | ```vim 56 | let g:python_highlight_all = 1 57 | ``` 58 | | Variable | Description | Default | 59 | | --------------------------------------------- | -------------------------------------------------------------- | ------- | 60 | | `g:python_version_2` | Python 2 mode | `0` | 61 | | `b:python_version_2` | Python 2 mode (buffer local) | `0` | 62 | | `g:python_highlight_builtins` | Highlight builtin objects, types, and functions | `0` | 63 | | `g:python_highlight_builtin_objs` | Highlight builtin objects only | `0` | 64 | | `g:python_highlight_builtin_types` | Highlight builtin types only | `0` | 65 | | `g:python_highlight_builtin_funcs` | Highlight builtin functions only | `0` | 66 | | `g:python_highlight_builtin_funcs_kwarg` | Highlight builtin functions when used as kwarg | `1` | 67 | | `g:python_highlight_exceptions` | Highlight standard exceptions | `0` | 68 | | `g:python_highlight_string_formatting` | Highlight `%` string formatting | `0` | 69 | | `g:python_highlight_string_format` | Highlight syntax of `str.format` syntax | `0` | 70 | | `g:python_highlight_string_templates` | Highlight syntax of `string.Template` | `0` | 71 | | `g:python_highlight_indent_errors` | Highlight indentation errors | `0` | 72 | | `g:python_highlight_space_errors` | Highlight trailing spaces | `0` | 73 | | `g:python_highlight_doctests` | Highlight doc-tests | `0` | 74 | | `g:python_highlight_func_calls` | Highlight functions calls | `0` | 75 | | `g:python_highlight_class_vars` | Highlight class variables `self`, `cls`, and `mcs` | `0` | 76 | | `g:python_highlight_operators` | Highlight all operators | `0` | 77 | | `g:python_highlight_all` | Enable all highlight options above, except for previously set. | `0` | 78 | | `g:python_highlight_file_headers_as_comments` | Highlight shebang and coding headers as comments | `0` | 79 | | `g:python_slow_sync` | Disable for slow machines | `1` | 80 | 81 | ### Commands 82 | 83 | | Command | Description | 84 | | --------------- | ------------------ | 85 | | `Python2Syntax` | Switch to Python 2 | 86 | | `Python3Syntax` | Switch to Python 3 | 87 | -------------------------------------------------------------------------------- /tests/test.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # Above the run-comment and file encoding comment. 4 | 5 | # Comments. 6 | 7 | # TODO FIXME XXX 8 | 9 | # Keywords. 10 | 11 | with break continue del return pass raise global assert lambda yield 12 | for while if elif else import as try except finally 13 | 14 | self cls mcs 15 | 16 | from test import var as name 17 | 18 | raise Exception from ex 19 | 20 | yield from 21 | 22 | def functionname 23 | functionname() 24 | functionname () 25 | functionname () 26 | test.functionname() 27 | test.functionname () 28 | class Classname 29 | class classname 30 | class classname_cls 31 | def функция 32 | функция() 33 | class Класс 34 | class класс 35 | 36 | 37 | # Keywords: Python 2 38 | 39 | exec 40 | print 41 | 42 | # Keywords: Python 3 43 | 44 | await 45 | async def Test 46 | async with 47 | async for 48 | 49 | # Builtin objects. 50 | 51 | True False Ellipsis None NotImplemented 52 | 53 | __debug__ __doc__ __file__ __name__ __package__ __loader__ __spec__ __path__ __cached__ 54 | 55 | # Bultin types 56 | 57 | bool bytearray dict float frozenset int list object set str tuple 58 | 59 | # Builtin functions 60 | 61 | __import__() 62 | abs() 63 | all() 64 | any() 65 | bin() 66 | bool() 67 | breakpoint() 68 | bytearray() 69 | callable() 70 | chr() 71 | classmethod() 72 | compile() 73 | complex() 74 | delattr() 75 | dict() 76 | dir() 77 | divmod() 78 | enumerate() 79 | eval() 80 | filter() 81 | float() 82 | format() 83 | frozenset() 84 | getattr() 85 | globals() 86 | hasattr() 87 | hash() 88 | help() 89 | hex() 90 | id() 91 | input() 92 | int() 93 | isinstance() 94 | issubclass() 95 | iter() 96 | len() 97 | list() 98 | locals() 99 | map() 100 | max() 101 | memoryview() 102 | min() 103 | next() 104 | object() 105 | oct() 106 | open() 107 | ord() 108 | pow() 109 | property() 110 | range() 111 | repr() 112 | reversed() 113 | round() 114 | set() 115 | setattr() 116 | slice() 117 | sorted() 118 | staticmethod() 119 | str() 120 | sum() 121 | super() 122 | tuple() 123 | type() 124 | vars() 125 | zip() 126 | 127 | # Builtin functions: Python 2 128 | 129 | apply() 130 | basestring() 131 | buffer() 132 | cmp() 133 | coerce() 134 | execfile() 135 | file() 136 | intern() 137 | long() 138 | raw_input() 139 | reduce() 140 | reload() 141 | unichr() 142 | unicode() 143 | xrange() 144 | 145 | print() 146 | 147 | # Builtin functions: Python 3 148 | 149 | ascii() 150 | bytes() 151 | exec() 152 | print() 153 | 154 | # Builtin exceptions and warnings. 155 | 156 | BaseException Exception StandardError ArithmeticError LookupError 157 | EnvironmentError 158 | 159 | AssertionError AttributeError EOFError FloatingPointError GeneratorExit IOError 160 | ImportError IndexError KeyError KeyboardInterrupt MemoryError NameError 161 | NotImplementedError OSError OverflowError ReferenceError RuntimeError 162 | StopIteration SyntaxError IndentationError TabError SystemError SystemExit 163 | TypeError UnboundLocalError UnicodeError UnicodeEncodeError UnicodeDecodeError 164 | UnicodeTranslateError ValueError WindowsError ZeroDivisionError 165 | 166 | Warning UserWarning DeprecationWarning PendingDeprecationWarning SyntaxWarning 167 | RuntimeWarning FutureWarning ImportWarning UnicodeWarning 168 | 169 | # Decorators. 170 | 171 | @ decoratorname 172 | @ object.__init__(arg1, arg2) 173 | @ декоратор 174 | @ декоратор.décorateur 175 | 176 | # Operators 177 | 178 | and or in is not 179 | 180 | - + * ** **- **+ **~ @ / // % 181 | & | ^ ~ << >> 182 | < <= == != >= > 183 | 184 | = =- =+ =~ 185 | -= += *= **= @= /= //= %= := 186 | &= |= ^= ~= <<= >>= 187 | 188 | -> 189 | 190 | # Erroneous operators 191 | 192 | $ ? 193 | === 194 | -- ++ *** @@ /// %% 195 | && || ^^ ~~ <<< >>> 196 | <== !== !!= >== 197 | %- +- -+ 198 | 199 | # Numbers 200 | 201 | 0 1 2 9 10 0x1f 1. .3 12.34 0j 124j 34.2E-3 0b10 0o77 1023434 0x0 202 | 1_1 1_1.2_2 1_2j 0x_1f 0x1_f 34_56e-3 34_56e+3_1 0o7_7 203 | 204 | # Erroneous numbers 205 | 206 | 077 100L 0xfffffffL 0L 08 0xk 0x 0b102 0o78 0o123LaB 207 | 0_ 0_1 0_x1f 0x1f_ 0_b77 0b77_ .2_ 1_j 208 | 209 | # Strings 210 | 211 | " test " ' test ' 212 | "test\ 213 | test" 214 | 'test\ 215 | test' 216 | 217 | """ 218 | test 219 | \"""" 220 | ''' 221 | test 222 | \'''' 223 | 224 | " \a\b\c\"\'\n\r \x34\077 \08 \xag" 225 | r" \" \' " 226 | 227 | "testтест" 228 | 229 | b"test" 230 | 231 | b"test\r\n\xffff" 232 | 233 | b"тестtest" 234 | 235 | br"test" 236 | 237 | br"\a\b\n\r" 238 | 239 | # Formattings 240 | 241 | " %f " 242 | b" %f " 243 | 244 | "{0.name!r:b} {0[n]} {name!s: } {{test}} {{}} {} {.__len__:s}" 245 | b"{0.name!r:b} {0[n]} {name!s: } {{test}} {{}} {} {.__len__:s}" 246 | 247 | "${test} ${test ${test}aname $$$ $test+nope" 248 | b"${test} ${test ${test}aname $$$ $test+nope" 249 | 250 | f"{var}...{arr[123]} normal {var['{'] // 0xff} \"xzcb\" 'xzcb' {var['}'] + 1} text" 251 | f"{expr1 if True or False else expr2} {None} wow {','.join(c.lower() for c in 'asdf')}" 252 | f"hello {expr:.2f} yes {(lambda: 0b1)():#03x} lol {var!r}" 253 | f'brackets: {{{ 1 + 2 }}} and {{{{ 3 + 4 }}}}' 254 | fr'this {that}' 255 | f"{f'{1+1}'}" 256 | '{{ }}' 257 | f"{"{test}"}" # FIXME: syntax error that should not be highlighted 258 | f'{self.__name__} 259 | 260 | # Doctests. 261 | 262 | """ 263 | Test: 264 | >>> a = 5 265 | >>> a 266 | 5 267 | 268 | Test 269 | """ 270 | 271 | ''' 272 | Test: 273 | >>> a = 5 274 | >>> a 275 | 5 276 | 277 | Test 278 | ''' 279 | 280 | # Erroneous variable names 281 | 282 | 6xav 283 | 284 | 285 | # Indentation errors. 286 | 287 | break 288 | 289 | # Trailing space errors. 290 | 291 | 292 | break 293 | """ 294 | 295 | test 296 | """ 297 | -------------------------------------------------------------------------------- /syntax/python.vim: -------------------------------------------------------------------------------- 1 | " For version 5.x: Clear all syntax items 2 | " For versions greater than 6.x: Quit when a syntax file was already loaded 3 | if v:version < 600 4 | syntax clear 5 | elseif exists('b:current_syntax') 6 | finish 7 | endif 8 | 9 | " 10 | " Commands 11 | " 12 | command! -buffer Python2Syntax let b:python_version_2 = 1 | let &syntax=&syntax 13 | command! -buffer Python3Syntax let b:python_version_2 = 0 | let &syntax=&syntax 14 | 15 | " Enable option if it's not defined 16 | function! s:EnableByDefault(name) 17 | if !exists(a:name) 18 | let {a:name} = 1 19 | endif 20 | endfunction 21 | 22 | " Check if option is enabled 23 | function! s:Enabled(name) 24 | return exists(a:name) && {a:name} 25 | endfunction 26 | 27 | " Is it Python 2 syntax? 28 | function! s:Python2Syntax() 29 | if exists('b:python_version_2') 30 | return b:python_version_2 31 | endif 32 | return s:Enabled('g:python_version_2') 33 | endfunction 34 | 35 | " 36 | " Default options 37 | " 38 | 39 | call s:EnableByDefault('g:python_slow_sync') 40 | call s:EnableByDefault('g:python_highlight_builtin_funcs_kwarg') 41 | 42 | if s:Enabled('g:python_highlight_all') 43 | call s:EnableByDefault('g:python_highlight_builtins') 44 | call s:EnableByDefault('g:python_highlight_exceptions') 45 | call s:EnableByDefault('g:python_highlight_string_formatting') 46 | call s:EnableByDefault('g:python_highlight_string_format') 47 | call s:EnableByDefault('g:python_highlight_string_templates') 48 | call s:EnableByDefault('g:python_highlight_indent_errors') 49 | call s:EnableByDefault('g:python_highlight_space_errors') 50 | call s:EnableByDefault('g:python_highlight_doctests') 51 | call s:EnableByDefault('g:python_print_as_function') 52 | call s:EnableByDefault('g:python_highlight_func_calls') 53 | call s:EnableByDefault('g:python_highlight_class_vars') 54 | call s:EnableByDefault('g:python_highlight_operators') 55 | endif 56 | 57 | if s:Enabled('g:python_highlight_builtins') 58 | call s:EnableByDefault('g:python_highlight_builtin_objs') 59 | call s:EnableByDefault('g:python_highlight_builtin_types') 60 | call s:EnableByDefault('g:python_highlight_builtin_funcs') 61 | endif 62 | 63 | " 64 | " Function calls 65 | " 66 | 67 | if s:Enabled('g:python_highlight_func_calls') 68 | syn match pythonFunctionCall '\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\ze\%(\s*(\)' 69 | endif 70 | 71 | " 72 | " Keywords 73 | " 74 | 75 | syn keyword pythonStatement break continue del return pass yield global assert lambda with 76 | syn keyword pythonStatement raise nextgroup=pythonExClass skipwhite 77 | syn keyword pythonStatement def nextgroup=pythonFunction skipwhite 78 | syn keyword pythonStatement class nextgroup=pythonClass skipwhite 79 | if s:Enabled('g:python_highlight_class_vars') 80 | syn keyword pythonClassVar self cls mcs 81 | endif 82 | syn keyword pythonRepeat for while 83 | syn keyword pythonConditional if elif else 84 | syn keyword pythonException try except finally 85 | " The standard pyrex.vim unconditionally removes the pythonInclude group, so 86 | " we provide a dummy group here to avoid crashing pyrex.vim. 87 | syn keyword pythonInclude import 88 | syn keyword pythonImport import 89 | syn match pythonRaiseFromStatement '\' 90 | syn match pythonImport '^\s*\zsfrom\>' 91 | 92 | 93 | if s:Python2Syntax() 94 | if !s:Enabled('g:python_print_as_function') 95 | syn keyword pythonStatement print 96 | endif 97 | syn keyword pythonStatement exec 98 | syn keyword pythonImport as 99 | syn match pythonFunction '[a-zA-Z_][a-zA-Z0-9_]*' display contained 100 | else 101 | syn keyword pythonStatement as nonlocal 102 | syn match pythonStatement '\v\.@' 103 | syn match pythonFunction '\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*' display contained 104 | syn match pythonClass '\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*' display contained 105 | syn match pythonStatement '\' nextgroup=pythonFunction skipwhite 106 | syn match pythonStatement '\' 107 | syn match pythonStatement '\' 108 | syn cluster pythonExpression contains=pythonStatement,pythonRepeat,pythonConditional,pythonOperator,pythonNumber,pythonHexNumber,pythonOctNumber,pythonBinNumber,pythonFloat,pythonString,pythonFString,pythonRawString,pythonRawFString,pythonBytes,pythonBoolean,pythonNone,pythonSingleton,pythonBuiltinObj,pythonBuiltinFunc,pythonBuiltinType,pythonClassVar 109 | endif 110 | 111 | 112 | " 113 | " Operators 114 | " 115 | syn keyword pythonOperator and in is not or 116 | if s:Enabled('g:python_highlight_operators') 117 | syn match pythonOperator '\V=\|-\|+\|*\|@\|/\|%\|&\||\|^\|~\|<\|>\|!=\|:=' 118 | endif 119 | syn match pythonError '[$?]\|\([-+@%&|^~]\)\1\{1,}\|\([=*/<>]\)\2\{2,}\|\([+@/%&|^~<>]\)\3\@![-+*@/%&|^~<>]\|\*\*[*@/%&|^<>]\|=[*@/%&|^<>]\|-[+*@/%&|^~<]\|[]\+=\{2,}\|!\{2,}=\+' display 120 | 121 | " 122 | " Decorators (new in Python 2.4) 123 | " 124 | 125 | syn match pythonDecorator '^\s*\zs@' display nextgroup=pythonDottedName skipwhite 126 | if s:Python2Syntax() 127 | syn match pythonDottedName '[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*' display contained 128 | else 129 | syn match pythonDottedName '\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\)*' display contained 130 | endif 131 | syn match pythonDot '\.' display containedin=pythonDottedName 132 | 133 | " 134 | " Comments 135 | " 136 | 137 | syn match pythonComment '#.*$' display contains=pythonTodo,@Spell 138 | if !s:Enabled('g:python_highlight_file_headers_as_comments') 139 | syn match pythonRun '\%^#!.*$' 140 | syn match pythonCoding '\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$' 141 | endif 142 | syn keyword pythonTodo TODO FIXME XXX contained 143 | 144 | " 145 | " Errors 146 | " 147 | 148 | syn match pythonError '\<\d\+[^0-9[:space:]]\+\>' display 149 | 150 | " Mixing spaces and tabs also may be used for pretty formatting multiline 151 | " statements 152 | if s:Enabled('g:python_highlight_indent_errors') 153 | syn match pythonIndentError '^\s*\%( \t\|\t \)\s*\S'me=e-1 display 154 | endif 155 | 156 | " Trailing space errors 157 | if s:Enabled('g:python_highlight_space_errors') 158 | syn match pythonSpaceError '\s\+$' display 159 | endif 160 | 161 | " 162 | " Strings 163 | " 164 | 165 | if s:Python2Syntax() 166 | " Python 2 strings 167 | syn region pythonString start=+[bB]\='+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell 168 | syn region pythonString start=+[bB]\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell 169 | syn region pythonString start=+[bB]\="""+ skip=+\\"+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell 170 | syn region pythonString start=+[bB]\='''+ skip=+\\'+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell 171 | else 172 | " Python 3 byte strings 173 | syn region pythonBytes start=+[bB]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell 174 | syn region pythonBytes start=+[bB]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell 175 | syn region pythonBytes start=+[bB]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest,pythonSpaceError,@Spell 176 | syn region pythonBytes start=+[bB]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest2,pythonSpaceError,@Spell 177 | 178 | syn match pythonBytesError '.\+' display contained 179 | syn match pythonBytesContent '[\u0000-\u00ff]\+' display contained contains=pythonBytesEscape,pythonBytesEscapeError 180 | endif 181 | 182 | syn match pythonBytesEscape +\\[abfnrtv'"\\]+ display contained 183 | syn match pythonBytesEscape '\\\o\o\=\o\=' display contained 184 | syn match pythonBytesEscapeError '\\\o\{,2}[89]' display contained 185 | syn match pythonBytesEscape '\\x\x\{2}' display contained 186 | syn match pythonBytesEscapeError '\\x\x\=\X' display contained 187 | syn match pythonBytesEscape '\\$' 188 | 189 | syn match pythonUniEscape '\\u\x\{4}' display contained 190 | syn match pythonUniEscapeError '\\u\x\{,3}\X' display contained 191 | syn match pythonUniEscape '\\U\x\{8}' display contained 192 | syn match pythonUniEscapeError '\\U\x\{,7}\X' display contained 193 | syn match pythonUniEscape '\\N{[A-Z ]\+}' display contained 194 | syn match pythonUniEscapeError '\\N{[^A-Z ]\+}' display contained 195 | 196 | if s:Python2Syntax() 197 | " Python 2 Unicode strings 198 | syn region pythonUniString start=+[uU]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell 199 | syn region pythonUniString start=+[uU]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell 200 | syn region pythonUniString start=+[uU]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell 201 | syn region pythonUniString start=+[uU]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell 202 | else 203 | " Python 3 strings 204 | syn region pythonString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell 205 | syn region pythonString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell 206 | syn region pythonString start=+'''+ skip=+\\'+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell 207 | syn region pythonString start=+"""+ skip=+\\"+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell 208 | 209 | syn region pythonFString start=+[fF]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell 210 | syn region pythonFString start=+[fF]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell 211 | syn region pythonFString start=+[fF]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell 212 | syn region pythonFString start=+[fF]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell 213 | endif 214 | 215 | if s:Python2Syntax() 216 | " Python 2 Unicode raw strings 217 | syn region pythonUniRawString start=+[uU][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell 218 | syn region pythonUniRawString start=+[uU][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell 219 | syn region pythonUniRawString start=+[uU][rR]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest,pythonSpaceError,@Spell 220 | syn region pythonUniRawString start=+[uU][rR]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest2,pythonSpaceError,@Spell 221 | 222 | syn match pythonUniRawEscape '\%([^\\]\%(\\\\\)*\)\@<=\\u\x\{4}' display contained 223 | syn match pythonUniRawEscapeError '\%([^\\]\%(\\\\\)*\)\@<=\\u\x\{,3}\X' display contained 224 | endif 225 | 226 | " Python 2/3 raw strings 227 | if s:Python2Syntax() 228 | syn region pythonRawString start=+[bB]\=[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell 229 | syn region pythonRawString start=+[bB]\=[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell 230 | syn region pythonRawString start=+[bB]\=[rR]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell 231 | syn region pythonRawString start=+[bB]\=[rR]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell 232 | else 233 | syn region pythonRawString start=+[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell 234 | syn region pythonRawString start=+[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell 235 | syn region pythonRawString start=+[rR]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell 236 | syn region pythonRawString start=+[rR]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell 237 | 238 | syn region pythonRawFString start=+\%([fF][rR]\|[rR][fF]\)'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell 239 | syn region pythonRawFString start=+\%([fF][rR]\|[rR][fF]\)"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell 240 | syn region pythonRawFString start=+\%([fF][rR]\|[rR][fF]\)'''+ skip=+\\'+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell 241 | syn region pythonRawFString start=+\%([fF][rR]\|[rR][fF]\)"""+ skip=+\\"+ end=+"""+ keepend contains=pythonDocTest,pythonSpaceError,@Spell 242 | 243 | syn region pythonRawBytes start=+\%([bB][rR]\|[rR][bB]\)'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell 244 | syn region pythonRawBytes start=+\%([bB][rR]\|[rR][bB]\)"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell 245 | syn region pythonRawBytes start=+\%([bB][rR]\|[rR][bB]\)'''+ skip=+\\'+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell 246 | syn region pythonRawBytes start=+\%([bB][rR]\|[rR][bB]\)"""+ skip=+\\"+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell 247 | endif 248 | 249 | syn match pythonRawEscape +\\['"]+ display contained 250 | 251 | if s:Enabled('g:python_highlight_string_formatting') 252 | " % operator string formatting 253 | if s:Python2Syntax() 254 | syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString,pythonBytesContent 255 | syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString,pythonBytesContent 256 | else 257 | syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonRawString,pythonBytesContent 258 | syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonRawString,pythonBytesContent 259 | endif 260 | endif 261 | 262 | if s:Enabled('g:python_highlight_string_format') 263 | " str.format syntax 264 | if s:Python2Syntax() 265 | syn match pythonStrFormat '{{\|}}' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString 266 | syn match pythonStrFormat '{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString 267 | else 268 | syn match pythonStrFormat "{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonRawString 269 | syn region pythonStrInterpRegion matchgroup=pythonStrFormat start="{" end="\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" extend contained containedin=pythonFString,pythonRawFString contains=pythonStrInterpRegion,@pythonExpression 270 | syn match pythonStrFormat "{{\|}}" contained containedin=pythonFString,pythonRawFString 271 | endif 272 | endif 273 | 274 | if s:Enabled('g:python_highlight_string_templates') 275 | " string.Template format 276 | if s:Python2Syntax() 277 | syn match pythonStrTemplate '\$\$' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString 278 | syn match pythonStrTemplate '\${[a-zA-Z_][a-zA-Z0-9_]*}' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString 279 | syn match pythonStrTemplate '\$[a-zA-Z_][a-zA-Z0-9_]*' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString 280 | else 281 | syn match pythonStrTemplate '\$\$' contained containedin=pythonString,pythonRawString 282 | syn match pythonStrTemplate '\${[a-zA-Z_][a-zA-Z0-9_]*}' contained containedin=pythonString,pythonRawString 283 | syn match pythonStrTemplate '\$[a-zA-Z_][a-zA-Z0-9_]*' contained containedin=pythonString,pythonRawString 284 | endif 285 | endif 286 | 287 | if s:Enabled('g:python_highlight_doctests') 288 | " DocTests 289 | syn region pythonDocTest start='^\s*>>>' skip=+\\'+ end=+'''+he=s-1 end='^\s*$' contained 290 | syn region pythonDocTest2 start='^\s*>>>' skip=+\\"+ end=+"""+he=s-1 end='^\s*$' contained 291 | endif 292 | 293 | " 294 | " Numbers (ints, longs, floats, complex) 295 | " 296 | 297 | if s:Python2Syntax() 298 | syn match pythonHexError '\<0[xX]\x*[g-zG-Z]\+\x*[lL]\=\>' display 299 | syn match pythonOctError '\<0[oO]\=\o*\D\+\d*[lL]\=\>' display 300 | syn match pythonBinError '\<0[bB][01]*\D\+\d*[lL]\=\>' display 301 | 302 | syn match pythonHexNumber '\<0[xX]\x\+[lL]\=\>' display 303 | syn match pythonOctNumber '\<0[oO]\o\+[lL]\=\>' display 304 | syn match pythonBinNumber '\<0[bB][01]\+[lL]\=\>' display 305 | 306 | syn match pythonNumberError '\<\d\+\D[lL]\=\>' display 307 | syn match pythonNumber '\<\d[lL]\=\>' display 308 | syn match pythonNumber '\<[0-9]\d\+[lL]\=\>' display 309 | syn match pythonNumber '\<\d\+[lLjJ]\>' display 310 | 311 | syn match pythonOctError '\<0[oO]\=\o*[8-9]\d*[lL]\=\>' display 312 | syn match pythonBinError '\<0[bB][01]*[2-9]\d*[lL]\=\>' display 313 | 314 | syn match pythonFloat '\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>' display 315 | syn match pythonFloat '\<\d\+[eE][+-]\=\d\+[jJ]\=\>' display 316 | syn match pythonFloat '\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=' display 317 | else 318 | syn match pythonOctError '\<0[oO]\=\o*\D\+\d*\>' display 319 | " pythonHexError comes after pythonOctError so that 0xffffl is pythonHexError 320 | syn match pythonHexError '\<0[xX]\x*[g-zG-Z]\x*\>' display 321 | syn match pythonBinError '\<0[bB][01]*\D\+\d*\>' display 322 | 323 | syn match pythonHexNumber '\<0[xX][_0-9a-fA-F]*\x\>' display 324 | syn match pythonOctNumber '\<0[oO][_0-7]*\o\>' display 325 | syn match pythonBinNumber '\<0[bB][_01]*[01]\>' display 326 | 327 | syn match pythonNumberError '\<\d[_0-9]*\D\>' display 328 | syn match pythonNumberError '\<0[_0-9]\+\>' display 329 | syn match pythonNumberError '\<0_x\S*\>' display 330 | syn match pythonNumberError '\<0[bBxXoO][_0-9a-fA-F]*_\>' display 331 | syn match pythonNumberError '\<\d[_0-9]*_\>' display 332 | syn match pythonNumber '\<\d\>' display 333 | syn match pythonNumber '\<[1-9][_0-9]*\d\>' display 334 | syn match pythonNumber '\<\d[jJ]\>' display 335 | syn match pythonNumber '\<[1-9][_0-9]*\d[jJ]\>' display 336 | 337 | syn match pythonOctError '\<0[oO]\=\o*[8-9]\d*\>' display 338 | syn match pythonBinError '\<0[bB][01]*[2-9]\d*\>' display 339 | 340 | syn match pythonFloat '\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=\>' display 341 | syn match pythonFloat '\<\d\%([_0-9]*\d\)\=[eE][+-]\=\d\%([_0-9]*\d\)\=[jJ]\=\>' display 342 | syn match pythonFloat '\<\d\%([_0-9]*\d\)\=\.\d\=\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=' display 343 | endif 344 | 345 | " 346 | " Builtin objects 347 | " 348 | 349 | if s:Enabled('g:python_highlight_builtin_objs') 350 | syn keyword pythonNone None 351 | syn keyword pythonBoolean True False 352 | syn keyword pythonSingleton Ellipsis NotImplemented 353 | syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ 354 | syn keyword pythonBuiltinObj __loader__ __spec__ __path__ __cached__ 355 | endif 356 | 357 | " 358 | " Builtin functions 359 | " 360 | 361 | if s:Enabled('g:python_highlight_builtin_funcs') 362 | let s:funcs_re = '__import__|abs|all|any|bin|callable|chr|classmethod|compile|complex|delattr|dir|divmod|enumerate|eval|filter|format|getattr|globals|hasattr|hash|help|hex|id|input|isinstance|issubclass|iter|len|locals|map|max|memoryview|min|next|oct|open|ord|pow|property|range|repr|reversed|round|setattr|slice|sorted|staticmethod|sum|super|type|vars|zip' 363 | 364 | if s:Python2Syntax() 365 | let s:funcs_re .= '|apply|basestring|buffer|cmp|coerce|execfile|file|intern|long|raw_input|reduce|reload|unichr|unicode|xrange' 366 | if s:Enabled('g:python_print_as_function') 367 | let s:funcs_re .= '|print' 368 | endif 369 | else 370 | let s:funcs_re .= '|ascii|breakpoint|exec|print' 371 | endif 372 | 373 | let s:funcs_re = 'syn match pythonBuiltinFunc ''\v\.@' 374 | 375 | if !s:Enabled('g:python_highlight_builtin_funcs_kwarg') 376 | let s:funcs_re .= '\=@!' 377 | endif 378 | 379 | execute s:funcs_re . '''' 380 | unlet s:funcs_re 381 | endif 382 | 383 | " 384 | " Builtin types 385 | " 386 | 387 | if s:Enabled('g:python_highlight_builtin_types') 388 | syn match pythonBuiltinType '\v\.@' 389 | endif 390 | 391 | 392 | " 393 | " Builtin exceptions and warnings 394 | " 395 | 396 | if s:Enabled('g:python_highlight_exceptions') 397 | let s:exs_re = 'BaseException|Exception|ArithmeticError|LookupError|EnvironmentError|AssertionError|AttributeError|BufferError|EOFError|FloatingPointError|GeneratorExit|IOError|ImportError|IndexError|KeyError|KeyboardInterrupt|MemoryError|NameError|NotImplementedError|OSError|OverflowError|ReferenceError|RuntimeError|StopIteration|SyntaxError|IndentationError|TabError|SystemError|SystemExit|TypeError|UnboundLocalError|UnicodeError|UnicodeEncodeError|UnicodeDecodeError|UnicodeTranslateError|ValueError|VMSError|WindowsError|ZeroDivisionError|Warning|UserWarning|BytesWarning|DeprecationWarning|PendingDeprecationWarning|SyntaxWarning|RuntimeWarning|FutureWarning|ImportWarning|UnicodeWarning' 398 | 399 | if s:Python2Syntax() 400 | let s:exs_re .= '|StandardError' 401 | else 402 | let s:exs_re .= '|BlockingIOError|ChildProcessError|ConnectionError|BrokenPipeError|ConnectionAbortedError|ConnectionRefusedError|ConnectionResetError|FileExistsError|FileNotFoundError|InterruptedError|IsADirectoryError|NotADirectoryError|PermissionError|ProcessLookupError|TimeoutError|StopAsyncIteration|ResourceWarning' 403 | endif 404 | 405 | execute 'syn match pythonExClass ''\v\.@''' 406 | unlet s:exs_re 407 | endif 408 | 409 | " 410 | " Misc 411 | " 412 | 413 | if s:Enabled('g:python_slow_sync') 414 | syn sync minlines=2000 415 | else 416 | " This is fast but code inside triple quoted strings screws it up. It 417 | " is impossible to fix because the only way to know if you are inside a 418 | " triple quoted string is to start from the beginning of the file. 419 | syn sync match pythonSync grouphere NONE '):$' 420 | syn sync maxlines=200 421 | endif 422 | 423 | if v:version >= 508 || !exists('did_python_syn_inits') 424 | if v:version <= 508 425 | let did_python_syn_inits = 1 426 | command -nargs=+ HiLink hi link 427 | else 428 | command -nargs=+ HiLink hi def link 429 | endif 430 | 431 | HiLink pythonStatement Statement 432 | HiLink pythonRaiseFromStatement Statement 433 | HiLink pythonImport Include 434 | HiLink pythonFunction Function 435 | HiLink pythonFunctionCall Function 436 | HiLink pythonConditional Conditional 437 | HiLink pythonRepeat Repeat 438 | HiLink pythonException Exception 439 | HiLink pythonOperator Operator 440 | 441 | HiLink pythonDecorator Define 442 | HiLink pythonDottedName Function 443 | 444 | HiLink pythonComment Comment 445 | if !s:Enabled('g:python_highlight_file_headers_as_comments') 446 | HiLink pythonCoding Special 447 | HiLink pythonRun Special 448 | endif 449 | HiLink pythonTodo Todo 450 | 451 | HiLink pythonError Error 452 | HiLink pythonIndentError Error 453 | HiLink pythonSpaceError Error 454 | 455 | HiLink pythonString String 456 | HiLink pythonRawString String 457 | HiLink pythonRawEscape Special 458 | 459 | HiLink pythonUniEscape Special 460 | HiLink pythonUniEscapeError Error 461 | 462 | if s:Python2Syntax() 463 | HiLink pythonUniString String 464 | HiLink pythonUniRawString String 465 | HiLink pythonUniRawEscape Special 466 | HiLink pythonUniRawEscapeError Error 467 | else 468 | HiLink pythonBytes String 469 | HiLink pythonRawBytes String 470 | HiLink pythonBytesContent String 471 | HiLink pythonBytesError Error 472 | HiLink pythonBytesEscape Special 473 | HiLink pythonBytesEscapeError Error 474 | HiLink pythonFString String 475 | HiLink pythonRawFString String 476 | endif 477 | 478 | HiLink pythonStrFormatting Special 479 | HiLink pythonStrFormat Special 480 | HiLink pythonStrTemplate Special 481 | 482 | HiLink pythonDocTest Special 483 | HiLink pythonDocTest2 Special 484 | 485 | HiLink pythonNumber Number 486 | HiLink pythonHexNumber Number 487 | HiLink pythonOctNumber Number 488 | HiLink pythonBinNumber Number 489 | HiLink pythonFloat Float 490 | HiLink pythonNumberError Error 491 | HiLink pythonOctError Error 492 | HiLink pythonHexError Error 493 | HiLink pythonBinError Error 494 | 495 | HiLink pythonBoolean Boolean 496 | HiLink pythonNone Constant 497 | HiLink pythonSingleton Constant 498 | 499 | HiLink pythonBuiltinObj Identifier 500 | HiLink pythonBuiltinFunc Function 501 | HiLink pythonBuiltinType Structure 502 | 503 | HiLink pythonExClass Structure 504 | HiLink pythonClass Structure 505 | HiLink pythonClassVar Identifier 506 | 507 | delcommand HiLink 508 | endif 509 | 510 | let b:current_syntax = 'python' 511 | --------------------------------------------------------------------------------