blob: a31fa308a2b491cb9aee8d46291ba53aee164d54 [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")
65 syn keyword pythonBuiltin unichr all set abs vars int __import__ unicode
Neal Norwitzce96f692006-03-17 06:49:51 +000066 syn keyword pythonBuiltin enumerate reduce exit issubclass
67 syn keyword pythonBuiltin divmod file Ellipsis isinstance open any
Brett Cannona4fe1822006-02-25 14:52:53 +000068 syn keyword pythonBuiltin locals help filter basestring slice copyright min
Neal Norwitzce96f692006-03-17 06:49:51 +000069 syn keyword pythonBuiltin super sum tuple hex execfile long id chr
Brett Cannona4fe1822006-02-25 14:52:53 +000070 syn keyword pythonBuiltin complex bool zip pow dict True oct NotImplemented
71 syn keyword pythonBuiltin map None float hash getattr buffer max reversed
72 syn keyword pythonBuiltin object quit len repr callable credits setattr
73 syn keyword pythonBuiltin eval frozenset sorted ord __debug__ hasattr
Neal Norwitzce96f692006-03-17 06:49:51 +000074 syn keyword pythonBuiltin delattr False license classmethod type
75 syn keyword pythonBuiltin list iter reload range globals
Brett Cannona4fe1822006-02-25 14:52:53 +000076 syn keyword pythonBuiltin staticmethod str property round dir cmp
77
78endif
79
80
81if exists("python_highlight_exceptions")
82 syn keyword pythonException GeneratorExit ImportError RuntimeError
83 syn keyword pythonException UnicodeTranslateError MemoryError StopIteration
84 syn keyword pythonException PendingDeprecationWarning EnvironmentError
85 syn keyword pythonException LookupError OSError DeprecationWarning
Brett Cannon20e192b2006-03-01 20:53:08 +000086 syn keyword pythonException UnicodeError UnicodeEncodeError
87 syn keyword pythonException FloatingPointError ReferenceError NameError
88 syn keyword pythonException OverflowWarning IOError SyntaxError
Brett Cannona4fe1822006-02-25 14:52:53 +000089 syn keyword pythonException FutureWarning SystemExit Exception EOFError
90 syn keyword pythonException StandardError ValueError TabError KeyError
91 syn keyword pythonException ZeroDivisionError SystemError
92 syn keyword pythonException UnicodeDecodeError IndentationError
93 syn keyword pythonException AssertionError TypeError IndexError
94 syn keyword pythonException RuntimeWarning KeyboardInterrupt UserWarning
95 syn keyword pythonException SyntaxWarning UnboundLocalError ArithmeticError
96 syn keyword pythonException Warning NotImplementedError AttributeError
Brett Cannon20e192b2006-03-01 20:53:08 +000097 syn keyword pythonException OverflowError BaseException
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"