blob: 21c375d9db79c061e0c5a48704030136eabbc0f5 [file] [log] [blame]
Brett Cannona4fe1822006-02-25 14:52:53 +00001" Auto-generated Vim syntax file for Python
2"
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__
66 syn keyword pythonBuiltin __import__ abs all any basestring bool
67 syn keyword pythonBuiltin buffer callable chr classmethod cmp
68 syn keyword pythonBuiltin complex copyright credits delattr dict
69 syn keyword pythonBuiltin dir divmod enumerate eval execfile exit file
70 syn keyword pythonBuiltin filter float frozenset getattr globals hasattr
71 syn keyword pythonBuiltin hash help hex id int isinstance
72 syn keyword pythonBuiltin issubclass iter len license list locals long map
73 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
76 syn keyword pythonBuiltin super tuple type unichr unicode vars zip
Brett Cannona4fe1822006-02-25 14:52:53 +000077
78endif
79
80
81if exists("python_highlight_exceptions")
Thomas Wouters89f507f2006-12-13 04:49:30 +000082 syn keyword pythonException ArithmeticError AssertionError AttributeError
83 syn keyword pythonException BaseException DeprecationWarning EOFError
84 syn keyword pythonException EnvironmentError Exception FloatingPointError
85 syn keyword pythonException FutureWarning GeneratorExit IOError ImportError
86 syn keyword pythonException ImportWarning IndentationError IndexError
87 syn keyword pythonException KeyError KeyboardInterrupt LookupError
88 syn keyword pythonException MemoryError NameError NotImplementedError
89 syn keyword pythonException OSError OverflowError PendingDeprecationWarning
90 syn keyword pythonException ReferenceError RuntimeError RuntimeWarning
91 syn keyword pythonException StandardError StopIteration SyntaxError
92 syn keyword pythonException SyntaxWarning SystemError SystemExit TabError
93 syn keyword pythonException TypeError UnboundLocalError UnicodeDecodeError
94 syn keyword pythonException UnicodeEncodeError UnicodeError
95 syn keyword pythonException UnicodeTranslateError UnicodeWarning
96 syn keyword pythonException UserWarning ValueError Warning
97 syn keyword pythonException ZeroDivisionError
Brett Cannona4fe1822006-02-25 14:52:53 +000098
99endif
100
101
102if exists("python_highlight_space_errors")
103 syn match pythonSpaceError display excludenl "\S\s\+$"ms=s+1
104 syn match pythonSpaceError display " \+\t"
105 syn match pythonSpaceError display "\t\+ "
106
107endif
108
109
110 hi def link pythonStatement Statement
111 hi def link pythonStatement Statement
112 hi def link pythonFunction Function
113 hi def link pythonRepeat Repeat
114 hi def link pythonConditional Conditional
115 hi def link pythonOperator Operator
116 hi def link pythonPreCondit PreCondit
117 hi def link pythonComment Comment
118 hi def link pythonTodo Todo
119 hi def link pythonString String
120 hi def link pythonEscape Special
121 hi def link pythonEscape Special
122
123 if exists("python_highlight_numbers")
124 hi def link pythonNumber Number
125 endif
126
127 if exists("python_highlight_builtins")
128 hi def link pythonBuiltin Function
129 endif
130
131 if exists("python_highlight_exceptions")
132 hi def link pythonException Exception
133 endif
134
135 if exists("python_highlight_space_errors")
136 hi def link pythonSpaceError Error
137 endif
138
139
140" Uncomment the 'minlines' statement line and comment out the 'maxlines'
141" statement line; changes behaviour to look at least 2000 lines previously for
142" syntax matches instead of at most 200 lines
143syn sync match pythonSync grouphere NONE "):$"
144syn sync maxlines=200
145"syn sync minlines=2000
146
147let b:current_syntax = "python"