forked from hdima/python-syntax
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython.vim.1.13
More file actions
237 lines (206 loc) · 9.74 KB
/
python.vim.1.13
File metadata and controls
237 lines (206 loc) · 9.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
" Vim syntax file
" Language: Python
" Maintainer: Neil Schemenauer <nas at python dot ca>
" Updated: $Date: 2003/01/12 14:17:34 $
" Updated by: Dmitry Vasiliev <dima at hlabs dot org>
" Filenames: *.py
" $Revision: 1.13 $
"
" Options:
" For folded functions and classes:
"
" let python_folding = 1
"
" For highlighted builtin functions:
"
" let python_highlight_builtins = 1
"
" For highlighted standard exceptions:
"
" let python_highlight_exceptions = 1
"
" For highlighted string formatting:
"
" let python_highlight_string_formatting = 1
"
" If you want all possible Python highlighting:
"
" let python_highlight_all = 1
"
" TODO: Check more errors?
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
if exists("python_highlight_all")
let python_folding = 1
let python_highlight_builtins = 1
let python_highlight_exceptions = 1
let python_highlight_string_formatting = 1
endif
" Keywords
syn keyword pythonStatement break continue del
syn keyword pythonStatement exec return
syn keyword pythonStatement pass print raise
syn keyword pythonStatement global assert
syn keyword pythonStatement lambda yield
if exists("python_folding") && has("folding")
syn match pythonStatement "\<\(def\|class\)\>" display nextgroup=pythonFunction skipwhite
else
syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite
endif
syn match pythonFunction "\h\w*" display contained
syn keyword pythonRepeat for while
syn keyword pythonConditional if elif else
syn keyword pythonImport import from as
syn keyword pythonException try except finally
syn keyword pythonOperator and in is not or
" Comments
syn match pythonComment "#.*$" display contains=pythonTodo
syn keyword pythonTodo TODO FIXME XXX contained
" Erroneous characters that cannont be in a python program
syn match pythonError "[@$?]" display
" Mixing spaces and tabs is bad
syn match pythonIndentError "^\s*\(\t \| \t\)\s*" display
" Strings
syn region pythonString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ contains=pythonEscape,pythonEscapeError
syn region pythonString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ contains=pythonEscape,pythonEscapeError
syn region pythonString start=+"""+ end=+"""+ contains=pythonEscape,pythonEscapeError
syn region pythonString start=+'''+ end=+'''+ contains=pythonEscape,pythonEscapeError
syn match pythonEscape +\\[abfnrtv'"\\]+ display contained
syn match pythonEscapeError +\\[^abfnrtv'"\\]+ display contained
syn match pythonEscape "\\\o\o\=\o\=" display contained
syn match pythonEscapeError "\\\o\{,2}[89]" display contained
syn match pythonEscape "\\x\x\{2}" display contained
syn match pythonEscapeError "\\x\x\=\X" display contained
syn match pythonEscape "\\$"
" Unicode strings
syn region pythonUniString start=+[uU]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError
syn region pythonUniString start=+[uU]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError
syn region pythonUniString start=+[uU]"""+ end=+"""+ contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError
syn region pythonUniString start=+[uU]'''+ end=+'''+ contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError
syn match pythonUniEscape "\\u\x\{4}" display contained
syn match pythonUniEscapeError "\\u\x\{,3}\X" display contained
syn match pythonUniEscape "\\U\x\{8}" display contained
syn match pythonUniEscapeError "\\U\x\{,7}\X" display contained
syn match pythonUniEscape "\\N{[A-Z ]\+}" display contained
syn match pythonUniEscapeError "\\N{[^A-Z ]\+}" display contained
" Raw strings
syn region pythonRawString start=+[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ contains=pythonRawEscape
syn region pythonRawString start=+[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ contains=pythonRawEscape
syn region pythonRawString start=+[rR]"""+ end=+"""+
syn region pythonRawString start=+[rR]'''+ end=+'''+
syn match pythonRawEscape +\\['"]+ display transparent contained
" Unicode raw strings
syn region pythonUniRawString start=+[uU][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError
syn region pythonUniRawString start=+[uU][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError
syn region pythonUniRawString start=+[uU][rR]"""+ end=+"""+ contains=pythonUniRawEscape,pythonUniRawEscapeError
syn region pythonUniRawString start=+[uU][rR]'''+ end=+'''+ contains=pythonUniRawEscape,pythonUniRawEscapeError
syn match pythonUniRawEscape "\([^\\]\(\\\\\)*\)\@<=\\u\x\{4}" display contained
syn match pythonUniRawEscapeError "\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display contained
if exists("python_highlight_string_formatting")
" String formatting
syn match pythonStrFormat "%\(([^)]\+)\)\=[-#0 +]\=\d*\(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString
syn match pythonStrFormat "%[-#0 +]\=\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString
endif
" Numbers (ints, longs, floats, complex)
syn match pythonNumber "\<0[xX]\x\+[lL]\=\>" display
syn match pythonNumber "\<\d\+[lLjJ]\=\>" display
syn match pythonFloat "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>" display
syn match pythonFloat "\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display
syn match pythonFloat "\<\d\+\.\d*\([eE][+-]\=\d\+\)\=[jJ]\=" display
syn match pythonOctalError "\<0\o*[89]\d*[lLjJ]\=\>" display
if exists("python_highlight_builtins")
" Builtin functions, types and objects, not really part of the syntax
syn keyword pythonBuiltinObj True False Ellipsis None NotImplemented
syn keyword pythonBuiltinFunc bool __import__ abs
syn keyword pythonBuiltinFunc apply buffer callable chr classmethod cmp
syn keyword pythonBuiltinFunc coerce compile complex delattr dict dir divmod
syn keyword pythonBuiltinFunc eval execfile file filter float getattr globals
syn keyword pythonBuiltinFunc hasattr hash hex id input int intern isinstance
syn keyword pythonBuiltinFunc issubclass iter len list locals long map max
syn keyword pythonBuiltinFunc min object oct open ord pow property range
syn keyword pythonBuiltinFunc raw_input reduce reload repr round setattr
syn keyword pythonBuiltinFunc slice staticmethod str super tuple type unichr
syn keyword pythonBuiltinFunc unicode vars xrange zip
endif
if exists("python_highlight_exceptions")
" Builtin exceptions and warnings
syn keyword pythonExClass ArithmeticError AssertionError AttributeError
syn keyword pythonExClass DeprecationWarning EOFError EnvironmentError
syn keyword pythonExClass Exception FloatingPointError IOError
syn keyword pythonExClass ImportError IndentiationError IndexError
syn keyword pythonExClass KeyError KeyboardInterrupt LookupError
syn keyword pythonExClass MemoryError NameError NotImplementedError
syn keyword pythonExClass OSError OverflowError OverflowWarning
syn keyword pythonExClass ReferenceError RuntimeError RuntimeWarning
syn keyword pythonExClass StandardError StopIteration SyntaxError
syn keyword pythonExClass SyntaxWarning SystemError SystemExit TabError
syn keyword pythonExClass TypeError UnboundLocalError UnicodeError
syn keyword pythonExClass UserWarning ValueError Warning WindowsError
syn keyword pythonExClass ZeroDivisionError
endif
syn sync clear
if exists("python_folding") && has("folding")
syn sync fromstart
"syn match pythonFold "^\(\s*\)\(class\|def\)\s.*\(\(\n\s*\)*\n\1\s\+\S.*\)\+" transparent fold
syn region pythonFold start="^\z(\s*\)\(class\|def\)\s" skip="^\z1\s\+\S" end="^\s*\S"me=s-1 transparent fold
syn region pythonFold start="{" end="}" transparent fold
syn region pythonFold start="\[" end="\]" transparent fold
else
" This is fast but code inside triple quoted strings screws it up. It
" is impossible to fix because the only way to know if you are inside a
" triple quoted string is to start from the beginning of the file. If
" you have a fast machine you can try uncommenting the "sync minlines"
" and commenting out the rest.
syn sync match pythonSync grouphere NONE "):$"
syn sync maxlines=200
"syn sync minlines=2000
endif
if version >= 508 || !exists("did_python_syn_inits")
if version <= 508
let did_python_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink pythonStatement Statement
HiLink pythonImport Statement
HiLink pythonFunction Function
HiLink pythonConditional Conditional
HiLink pythonRepeat Repeat
HiLink pythonException Exception
HiLink pythonOperator Operator
HiLink pythonComment Comment
HiLink pythonTodo Todo
HiLink pythonError Error
HiLink pythonIndentError Error
HiLink pythonString String
HiLink pythonUniString String
HiLink pythonRawString String
HiLink pythonUniRawString String
HiLink pythonEscape Special
HiLink pythonEscapeError Error
HiLink pythonUniEscape Special
HiLink pythonUniEscapeError Error
HiLink pythonUniRawEscape Special
HiLink pythonUniRawEscapeError Error
if exists("python_highlight_string_formatting")
HiLink pythonStrFormat Special
endif
HiLink pythonNumber Number
HiLink pythonFloat Float
HiLink pythonOctalError Error
if exists("python_highlight_builtins")
HiLink pythonBuiltinObj Structure
HiLink pythonBuiltinFunc Function
endif
if exists("python_highlight_exceptions")
HiLink pythonExClass Structure
endif
delcommand HiLink
endif
let b:current_syntax = "python"