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