blob: 11ee7eb2eb00a05e26132da292de76a0a412fd22 [file] [log] [blame]
Christian Heimesfd66e512008-01-29 12:18:50 +00001" Auto-generated Vim syntax file for Python (trunk: r60376M).
Brett Cannona4fe1822006-02-25 14:52:53 +00002"
3" To use: copy or symlink to ~/.vim/syntax/python.vim
4
5
6if exists("b:current_syntax")
7 finish
8endif
9
10if exists("python_highlight_all")
11 let python_highlight_numbers = 1
12 let python_highlight_builtins = 1
13 let python_highlight_exceptions = 1
14 let python_highlight_space_errors = 1
15endif
16
Brett Cannon20e192b2006-03-01 20:53:08 +000017syn keyword pythonStatement as assert break continue del except exec finally
18syn keyword pythonStatement global lambda pass print raise return try with
19syn keyword pythonStatement yield
Brett Cannona4fe1822006-02-25 14:52:53 +000020
21syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite
22
23syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" contained
24
25syn keyword pythonRepeat for while
26
27syn keyword pythonConditional if elif else
28
29syn keyword pythonOperator and in is not or
30
31syn keyword pythonPreCondit import from
32
33syn match pythonComment "#.*$" contains=pythonTodo
34
35syn keyword pythonTodo TODO FIXME XXX contained
36
37syn region pythonString matchgroup=Normal start=+[uU]\='+ end=+'+ skip=+\\\\\|\\'+ contains=pythonEscape
38syn region pythonString matchgroup=Normal start=+[uU]\="+ end=+"+ skip=+\\\\\|\\"+ contains=pythonEscape
39syn region pythonString matchgroup=Normal start=+[uU]\="""+ end=+"""+ contains=pythonEscape
40syn region pythonString matchgroup=Normal start=+[uU]\='''+ end=+'''+ contains=pythonEscape
41syn region pythonString matchgroup=Normal start=+[uU]\=[rR]'+ end=+'+ skip=+\\\\\|\\'+
42syn region pythonString matchgroup=Normal start=+[uU]\=[rR]"+ end=+"+ skip=+\\\\\|\\"+
43syn region pythonString matchgroup=Normal start=+[uU]\=[rR]"""+ end=+"""+
44syn region pythonString matchgroup=Normal start=+[uU]\=[rR]'''+ end=+'''+
45
46syn match pythonEscape +\\[abfnrtv\'"\\]+ contained
47syn match pythonEscape "\\\o\{1,3}" contained
48syn match pythonEscape "\\x\x\{2}" contained
49syn match pythonEscape "\(\\u\x\{4}\|\\U\x\{8}\)" contained
50
51syn match pythonEscape "\\$"
52
53
54if exists("python_highlight_numbers")
55 syn match pythonNumber "\<0x\x\+[Ll]\=\>"
56 syn match pythonNumber "\<\d\+[LljJ]\=\>"
57 syn match pythonNumber "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
58 syn match pythonNumber "\<\d\+\.\([eE][+-]\=\d\+\)\=[jJ]\=\>"
59 syn match pythonNumber "\<\d\+\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
60
61endif
62
63
64if exists("python_highlight_builtins")
Thomas Wouters89f507f2006-12-13 04:49:30 +000065 syn keyword pythonBuiltin Ellipsis False None NotImplemented True __debug__
Christian Heimesfd66e512008-01-29 12:18:50 +000066 syn keyword pythonBuiltin __import__ abs all any bool
Thomas Wouters89f507f2006-12-13 04:49:30 +000067 syn keyword pythonBuiltin buffer callable chr classmethod cmp
68 syn keyword pythonBuiltin complex copyright credits delattr dict
Neal Norwitz01688022007-08-12 00:43:29 +000069 syn keyword pythonBuiltin dir divmod enumerate eval exec exit
Thomas Wouters89f507f2006-12-13 04:49:30 +000070 syn keyword pythonBuiltin filter float frozenset getattr globals hasattr
71 syn keyword pythonBuiltin hash help hex id int isinstance
Neal Norwitz01688022007-08-12 00:43:29 +000072 syn keyword pythonBuiltin issubclass iter len license list locals map
Thomas Wouters89f507f2006-12-13 04:49:30 +000073 syn keyword pythonBuiltin max min object oct open ord pow property quit
74 syn keyword pythonBuiltin range reload repr reversed round
75 syn keyword pythonBuiltin set setattr slice sorted staticmethod str sum
Christian Heimesfd66e512008-01-29 12:18:50 +000076 syn keyword pythonBuiltin super trunc tuple type unicode vars
77 syn keyword pythonBuiltin zip
Brett Cannona4fe1822006-02-25 14:52:53 +000078
79endif
80
81
82if exists("python_highlight_exceptions")
Thomas Wouters89f507f2006-12-13 04:49:30 +000083 syn keyword pythonException ArithmeticError AssertionError AttributeError
84 syn keyword pythonException BaseException DeprecationWarning EOFError
85 syn keyword pythonException EnvironmentError Exception FloatingPointError
86 syn keyword pythonException FutureWarning GeneratorExit IOError ImportError
87 syn keyword pythonException ImportWarning IndentationError IndexError
88 syn keyword pythonException KeyError KeyboardInterrupt LookupError
89 syn keyword pythonException MemoryError NameError NotImplementedError
90 syn keyword pythonException OSError OverflowError PendingDeprecationWarning
91 syn keyword pythonException ReferenceError RuntimeError RuntimeWarning
Guido van Rossumcd16bf62007-06-13 18:07:49 +000092 syn keyword pythonException StopIteration SyntaxError
Thomas Wouters89f507f2006-12-13 04:49:30 +000093 syn keyword pythonException SyntaxWarning SystemError SystemExit TabError
94 syn keyword pythonException TypeError UnboundLocalError UnicodeDecodeError
95 syn keyword pythonException UnicodeEncodeError UnicodeError
96 syn keyword pythonException UnicodeTranslateError UnicodeWarning
97 syn keyword pythonException UserWarning ValueError Warning
98 syn keyword pythonException ZeroDivisionError
Brett Cannona4fe1822006-02-25 14:52:53 +000099
100endif
101
102
103if exists("python_highlight_space_errors")
104 syn match pythonSpaceError display excludenl "\S\s\+$"ms=s+1
105 syn match pythonSpaceError display " \+\t"
106 syn match pythonSpaceError display "\t\+ "
107
108endif
109
110
111 hi def link pythonStatement Statement
112 hi def link pythonStatement Statement
113 hi def link pythonFunction Function
114 hi def link pythonRepeat Repeat
115 hi def link pythonConditional Conditional
116 hi def link pythonOperator Operator
117 hi def link pythonPreCondit PreCondit
118 hi def link pythonComment Comment
119 hi def link pythonTodo Todo
120 hi def link pythonString String
121 hi def link pythonEscape Special
122 hi def link pythonEscape Special
123
124 if exists("python_highlight_numbers")
125 hi def link pythonNumber Number
126 endif
127
128 if exists("python_highlight_builtins")
129 hi def link pythonBuiltin Function
130 endif
131
132 if exists("python_highlight_exceptions")
133 hi def link pythonException Exception
134 endif
135
136 if exists("python_highlight_space_errors")
137 hi def link pythonSpaceError Error
138 endif
139
140
141" Uncomment the 'minlines' statement line and comment out the 'maxlines'
142" statement line; changes behaviour to look at least 2000 lines previously for
143" syntax matches instead of at most 200 lines
144syn sync match pythonSync grouphere NONE "):$"
145syn sync maxlines=200
146"syn sync minlines=2000
147
148let b:current_syntax = "python"