blob: 6a1fa9f40df6221f337e9639375c2e49be0f610c [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
17syn keyword pythonStatement assert break continue del except exec finally
18syn keyword pythonStatement global lambda pass print raise return try yield
19
20syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite
21
22syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" contained
23
24syn keyword pythonRepeat for while
25
26syn keyword pythonConditional if elif else
27
28syn keyword pythonOperator and in is not or
29
30syn keyword pythonPreCondit import from
31
32syn match pythonComment "#.*$" contains=pythonTodo
33
34syn keyword pythonTodo TODO FIXME XXX contained
35
36syn region pythonString matchgroup=Normal start=+[uU]\='+ end=+'+ skip=+\\\\\|\\'+ contains=pythonEscape
37syn region pythonString matchgroup=Normal start=+[uU]\="+ end=+"+ skip=+\\\\\|\\"+ contains=pythonEscape
38syn region pythonString matchgroup=Normal start=+[uU]\="""+ end=+"""+ contains=pythonEscape
39syn region pythonString matchgroup=Normal start=+[uU]\='''+ end=+'''+ contains=pythonEscape
40syn region pythonString matchgroup=Normal start=+[uU]\=[rR]'+ end=+'+ skip=+\\\\\|\\'+
41syn region pythonString matchgroup=Normal start=+[uU]\=[rR]"+ end=+"+ skip=+\\\\\|\\"+
42syn region pythonString matchgroup=Normal start=+[uU]\=[rR]"""+ end=+"""+
43syn region pythonString matchgroup=Normal start=+[uU]\=[rR]'''+ end=+'''+
44
45syn match pythonEscape +\\[abfnrtv\'"\\]+ contained
46syn match pythonEscape "\\\o\{1,3}" contained
47syn match pythonEscape "\\x\x\{2}" contained
48syn match pythonEscape "\(\\u\x\{4}\|\\U\x\{8}\)" contained
49
50syn match pythonEscape "\\$"
51
52
53if exists("python_highlight_numbers")
54 syn match pythonNumber "\<0x\x\+[Ll]\=\>"
55 syn match pythonNumber "\<\d\+[LljJ]\=\>"
56 syn match pythonNumber "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
57 syn match pythonNumber "\<\d\+\.\([eE][+-]\=\d\+\)\=[jJ]\=\>"
58 syn match pythonNumber "\<\d\+\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
59
60endif
61
62
63if exists("python_highlight_builtins")
64 syn keyword pythonBuiltin unichr all set abs vars int __import__ unicode
65 syn keyword pythonBuiltin enumerate reduce coerce intern exit issubclass
66 syn keyword pythonBuiltin divmod file Ellipsis apply isinstance open any
67 syn keyword pythonBuiltin locals help filter basestring slice copyright min
68 syn keyword pythonBuiltin super sum tuple hex execfile long id xrange chr
69 syn keyword pythonBuiltin complex bool zip pow dict True oct NotImplemented
70 syn keyword pythonBuiltin map None float hash getattr buffer max reversed
71 syn keyword pythonBuiltin object quit len repr callable credits setattr
72 syn keyword pythonBuiltin eval frozenset sorted ord __debug__ hasattr
73 syn keyword pythonBuiltin delattr False input license classmethod type
74 syn keyword pythonBuiltin raw_input list iter compile reload range globals
75 syn keyword pythonBuiltin staticmethod str property round dir cmp
76
77endif
78
79
80if exists("python_highlight_exceptions")
81 syn keyword pythonException GeneratorExit ImportError RuntimeError
82 syn keyword pythonException UnicodeTranslateError MemoryError StopIteration
83 syn keyword pythonException PendingDeprecationWarning EnvironmentError
84 syn keyword pythonException LookupError OSError DeprecationWarning
85 syn keyword pythonException UnicodeError FloatingPointError ReferenceError
86 syn keyword pythonException NameError OverflowWarning IOError SyntaxError
87 syn keyword pythonException FutureWarning SystemExit Exception EOFError
88 syn keyword pythonException StandardError ValueError TabError KeyError
89 syn keyword pythonException ZeroDivisionError SystemError
90 syn keyword pythonException UnicodeDecodeError IndentationError
91 syn keyword pythonException AssertionError TypeError IndexError
92 syn keyword pythonException RuntimeWarning KeyboardInterrupt UserWarning
93 syn keyword pythonException SyntaxWarning UnboundLocalError ArithmeticError
94 syn keyword pythonException Warning NotImplementedError AttributeError
95 syn keyword pythonException OverflowError UnicodeEncodeError
96
97endif
98
99
100if exists("python_highlight_space_errors")
101 syn match pythonSpaceError display excludenl "\S\s\+$"ms=s+1
102 syn match pythonSpaceError display " \+\t"
103 syn match pythonSpaceError display "\t\+ "
104
105endif
106
107
108 hi def link pythonStatement Statement
109 hi def link pythonStatement Statement
110 hi def link pythonFunction Function
111 hi def link pythonRepeat Repeat
112 hi def link pythonConditional Conditional
113 hi def link pythonOperator Operator
114 hi def link pythonPreCondit PreCondit
115 hi def link pythonComment Comment
116 hi def link pythonTodo Todo
117 hi def link pythonString String
118 hi def link pythonEscape Special
119 hi def link pythonEscape Special
120
121 if exists("python_highlight_numbers")
122 hi def link pythonNumber Number
123 endif
124
125 if exists("python_highlight_builtins")
126 hi def link pythonBuiltin Function
127 endif
128
129 if exists("python_highlight_exceptions")
130 hi def link pythonException Exception
131 endif
132
133 if exists("python_highlight_space_errors")
134 hi def link pythonSpaceError Error
135 endif
136
137
138" Uncomment the 'minlines' statement line and comment out the 'maxlines'
139" statement line; changes behaviour to look at least 2000 lines previously for
140" syntax matches instead of at most 200 lines
141syn sync match pythonSync grouphere NONE "):$"
142syn sync maxlines=200
143"syn sync minlines=2000
144
145let b:current_syntax = "python"