├── README.md ├── colors └── molokai.vim └── syntax └── python.vim /README.md: -------------------------------------------------------------------------------- 1 | Pretty Vim Python 0.1 2 | ===================== 3 | 4 | ![Imgur](http://i.imgur.com/RQ9mt.png) 5 | 6 | This is my attempt to make the python syntax highlighting in Vim look like Textmate's. 7 | 8 | Important 9 | --------- 10 | 11 | In the syntax folder is the **python.vim** which does the syntax highlighting for Python. Just replace yours with mine 12 | but remember to backup beforehand. 13 | 14 | Next I had to add another color definition to the **molokai.vim** stylesheet. This is probably not a very good idea 15 | because the new color definition will not be available for a different color theme. So in your colors folder 16 | add this molokai.vim and remember to select it as your default colorscheme. 17 | 18 | The changes made in the files are highlighted with comments and begins with **NOTE: @pfdevilliers added this**. 19 | 20 | 21 | General 22 | ------- 23 | 24 | The additions are still very much a hack job and must be improved upon. I think there are still two issues to 25 | sort out to duplicate the functionality of the Textmate highlighting, but I guess it is usable. 26 | -------------------------------------------------------------------------------- /colors/molokai.vim: -------------------------------------------------------------------------------- 1 | " Vim color file 2 | " 3 | " Author: Tomas Restrepo 4 | " Modified by: Steve Losh 5 | " 6 | " Note: Based on the monokai theme for textmate 7 | " by Wimer Hazenberg and its darker variant 8 | " by Hamish Stuart Macpherson 9 | " 10 | 11 | hi clear 12 | 13 | set background=dark 14 | let g:colors_name="molokai" 15 | 16 | " Basic Layout {{{ 17 | hi Normal guifg=#F8F8F2 guibg=#1B1E1F 18 | hi Folded guifg=#666666 guibg=bg 19 | hi CursorLine guibg=#232728 20 | hi CursorColumn guibg=#232728 21 | hi ColorColumn guibg=#232728 22 | hi LineNr guifg=#AAAAAA guibg=bg 23 | hi FoldColumn guifg=#AAAAAA guibg=bg 24 | hi VertSplit guifg=#AAAAAA guibg=bg gui=none 25 | hi Search guifg=#000000 guibg=#E4E500 26 | hi IncSearch guibg=#000000 guifg=#FF8D00 27 | " }}} 28 | " Syntax {{{ 29 | hi Boolean guifg=#AE81FF 30 | hi Comment guifg=#5c7176 31 | hi Character guifg=#E6DB74 32 | hi Number guifg=#AE81FF 33 | hi String guifg=#E6DB74 34 | hi Conditional guifg=#F92672 gui=bold 35 | hi Constant guifg=#AE81FF gui=bold 36 | hi Debug guifg=#BCA3A3 gui=bold 37 | hi Define guifg=#66D9EF 38 | hi Delimiter guifg=#8F8F8F 39 | hi Float guifg=#AE81FF 40 | hi Function guifg=#A6E22E 41 | hi Identifier guifg=#FD971F 42 | hi Builtin guifg=#AE81FF gui=bold 43 | " }}} 44 | " Diffs {{{ 45 | hi DiffAdd guibg=#0F1D0B 46 | hi DiffChange guifg=#89807D guibg=#322F2D 47 | hi DiffDelete guifg=#960050 guibg=#1E0010 48 | hi DiffText guibg=#4A4340 gui=italic,bold 49 | " }}} 50 | " Cursor {{{ 51 | hi Cursor guifg=#000000 guibg=#F35FBC 52 | hi iCursor guifg=#000000 guibg=#FDFF00 53 | hi vCursor guifg=#000000 guibg=#AAF412 54 | " }}} 55 | 56 | hi GreenBar term=reverse ctermfg=white ctermbg=green guifg=#FFFFFF guibg=#604A8C 57 | hi RedBar term=reverse ctermfg=white ctermbg=red guifg=#FFFFFF guibg=#C50048 58 | 59 | hi EasyMotionTarget guifg=#E4E500 guibg=bg gui=bold 60 | hi EasyMotionShade guifg=#444444 guibg=bg gui=bold 61 | hi Directory guifg=#A6E22E gui=bold 62 | hi Error guifg=#960050 guibg=#1E0010 63 | hi ErrorMsg guifg=#F92672 guibg=#232526 gui=bold 64 | hi Exception guifg=#A6E22E gui=bold 65 | hi Ignore guifg=#808080 guibg=bg 66 | 67 | hi Keyword guifg=#F92672 gui=bold 68 | hi Label guifg=#E6DB74 gui=none 69 | hi Macro guifg=#C4BE89 gui=italic 70 | hi SpecialKey guifg=#66D9EF gui=italic 71 | 72 | hi InterestingWord1 guifg=#000000 guibg=#FFA700 73 | hi InterestingWord2 guifg=#000000 guibg=#53FF00 74 | hi InterestingWord3 guifg=#000000 guibg=#FF74F8 75 | 76 | hi MatchParen guifg=#E4E400 guibg=#434748 gui=bold 77 | hi ModeMsg guifg=#E6DB74 78 | hi MoreMsg guifg=#E6DB74 79 | hi Operator guifg=#F92672 80 | 81 | " Completion Menu {{{ 82 | hi Pmenu guifg=#cccccc guibg=#232728 83 | hi PmenuSel guifg=#000000 guibg=#AAF412 84 | hi PmenuSbar guibg=#131414 85 | hi PmenuThumb guifg=#777777 86 | " }}} 87 | 88 | hi PreCondit guifg=#A6E22E gui=bold 89 | hi PreProc guifg=#A6E22E 90 | hi Question guifg=#66D9EF 91 | hi Repeat guifg=#F92672 gui=bold 92 | 93 | " marks column 94 | hi IndentGuides guibg=#373737 95 | hi SignColumn guifg=#A6E22E guibg=#151617 96 | hi SpecialChar guifg=#F92672 gui=bold 97 | hi SpecialComment guifg=#465457 gui=bold 98 | hi Special guifg=#66D9EF guibg=bg gui=italic 99 | hi SpecialKey guifg=#888A85 gui=italic 100 | hi Statement guifg=#F92672 gui=bold 101 | hi StatusLine guifg=#CD5907 guibg=fg 102 | hi StatusLineNC guifg=#808080 guibg=#080808 103 | hi StorageClass guifg=#FD971F gui=italic 104 | " Structure is the light blue color 105 | hi Structure guifg=#66D9EF 106 | hi Tag guifg=#F92672 gui=italic 107 | hi Title guifg=#ef5939 108 | hi Todo guifg=#FFFFFF guibg=bg gui=bold 109 | 110 | hi Typedef guifg=#66D9EF 111 | hi Type guifg=#66D9EF gui=none 112 | hi Underlined guifg=#808080 gui=underline 113 | 114 | hi WarningMsg guifg=#FFFFFF guibg=#333333 gui=bold 115 | hi WildMenu guifg=#66D9EF guibg=#000000 116 | 117 | hi MyTagListFileName guifg=#F92672 guibg=bg gui=bold 118 | 119 | " Spelling {{{ 120 | if has("spell") 121 | hi SpellBad guisp=#FF0000 gui=undercurl 122 | hi SpellCap guisp=#7070F0 gui=undercurl 123 | hi SpellLocal guisp=#70F0F0 gui=undercurl 124 | hi SpellRare guisp=#FFFFFF gui=undercurl 125 | endif 126 | " }}} 127 | " Visual Mode {{{ 128 | hi VisualNOS guibg=#403D3D 129 | hi Visual guibg=#403D3D 130 | " }}} 131 | " Invisible character colors {{{ 132 | highlight NonText guifg=#444444 guibg=bg 133 | highlight SpecialKey guifg=#444444 guibg=bg 134 | " }}} 135 | 136 | " Support for 256-color terminals {{{ 137 | if &t_Co > 255 138 | hi Boolean ctermfg=135 139 | hi Character ctermfg=144 140 | hi Number ctermfg=135 141 | hi String ctermfg=144 142 | hi Conditional ctermfg=161 cterm=bold 143 | hi Constant ctermfg=135 cterm=bold 144 | hi Cursor ctermfg=16 ctermbg=253 145 | hi Debug ctermfg=225 cterm=bold 146 | hi Define ctermfg=81 147 | hi Delimiter ctermfg=241 148 | hi Builtin ctermfg=135 cterm=bold 149 | 150 | hi EasyMotionTarget ctermfg=11 151 | hi EasyMotionShade ctermfg=8 152 | 153 | hi DiffAdd ctermbg=24 154 | hi DiffChange ctermfg=181 ctermbg=239 155 | hi DiffDelete ctermfg=162 ctermbg=53 156 | hi DiffText ctermbg=102 cterm=bold 157 | 158 | hi Directory ctermfg=118 cterm=bold 159 | hi Error ctermfg=219 ctermbg=89 160 | hi ErrorMsg ctermfg=199 ctermbg=16 cterm=bold 161 | hi Exception ctermfg=118 cterm=bold 162 | hi Float ctermfg=135 163 | hi FoldColumn ctermfg=67 ctermbg=233 164 | hi Folded ctermfg=67 ctermbg=233 165 | hi Function ctermfg=118 166 | hi Identifier ctermfg=208 167 | hi Ignore ctermfg=244 ctermbg=232 168 | hi IncSearch ctermfg=193 ctermbg=16 169 | 170 | hi Keyword ctermfg=161 cterm=bold 171 | hi Label ctermfg=229 cterm=none 172 | hi Macro ctermfg=193 173 | hi SpecialKey ctermfg=81 174 | hi MailHeaderEmail ctermfg=3 ctermbg=233 175 | hi MailEmail ctermfg=3 ctermbg=233 176 | 177 | hi MatchParen ctermfg=16 ctermbg=208 cterm=bold 178 | hi ModeMsg ctermfg=229 179 | hi MoreMsg ctermfg=229 180 | hi Operator ctermfg=161 181 | 182 | " complete menu 183 | hi Pmenu ctermfg=81 ctermbg=16 184 | hi PmenuSel ctermbg=244 185 | hi PmenuSbar ctermbg=232 186 | hi PmenuThumb ctermfg=81 187 | 188 | hi PreCondit ctermfg=118 cterm=bold 189 | hi PreProc ctermfg=118 190 | hi Question ctermfg=81 191 | hi Repeat ctermfg=161 cterm=bold 192 | hi Search ctermfg=253 ctermbg=66 193 | 194 | " marks column 195 | hi SignColumn ctermfg=118 ctermbg=235 196 | hi SpecialChar ctermfg=161 cterm=bold 197 | hi SpecialComment ctermfg=245 cterm=bold 198 | hi Special ctermfg=81 ctermbg=232 199 | hi SpecialKey ctermfg=245 200 | 201 | hi Statement ctermfg=161 cterm=bold 202 | hi StatusLine ctermfg=238 ctermbg=253 203 | hi StatusLineNC ctermfg=244 ctermbg=232 204 | hi StorageClass ctermfg=208 205 | hi Structure ctermfg=81 206 | hi Tag ctermfg=161 207 | hi Title ctermfg=166 208 | hi Todo ctermfg=231 ctermbg=232 cterm=bold 209 | 210 | hi Typedef ctermfg=81 211 | hi Type ctermfg=81 cterm=none 212 | hi Underlined ctermfg=244 cterm=underline 213 | 214 | " NOTE: @pfdevilliers added this shit 215 | " Not sure if this color with underlined was defined already 216 | " but I added it for the definition of a class that is a 217 | " subclass. 218 | hi InheritUnderlined ctermfg=118 cterm=underline 219 | 220 | hi VertSplit ctermfg=244 ctermbg=232 cterm=bold 221 | hi VisualNOS ctermbg=238 222 | hi Visual ctermbg=235 223 | hi WarningMsg ctermfg=231 ctermbg=238 cterm=bold 224 | hi WildMenu ctermfg=81 ctermbg=16 225 | 226 | hi Normal ctermfg=252 ctermbg=233 227 | hi Comment ctermfg=59 228 | hi CursorLine ctermbg=234 cterm=none 229 | hi CursorColumn ctermbg=234 230 | hi ColorColumn ctermbg=234 231 | hi LineNr ctermfg=250 ctermbg=233 232 | hi NonText ctermfg=240 ctermbg=233 233 | end " }}} 234 | -------------------------------------------------------------------------------- /syntax/python.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Python 3 | " Maintainer: Neil Schemenauer 4 | " Last Change: 2009-10-13 5 | " Credits: Zvezdan Petkovic 6 | " Neil Schemenauer 7 | " Dmitry Vasiliev 8 | " 9 | " This version is a major rewrite by Zvezdan Petkovic. 10 | " 11 | " - introduced highlighting of doctests 12 | " - updated keywords, built-ins, and exceptions 13 | " - corrected regular expressions for 14 | " 15 | " * functions 16 | " * decorators 17 | " * strings 18 | " * escapes 19 | " * numbers 20 | " * space error 21 | " 22 | " - corrected synchronization 23 | " - more highlighting is ON by default, except 24 | " - space error highlighting is OFF by default 25 | " 26 | " Optional highlighting can be controlled using these variables. 27 | " 28 | " let python_no_builtin_highlight = 1 29 | " let python_no_doctest_code_highlight = 1 30 | " let python_no_doctest_highlight = 1 31 | " let python_no_exception_highlight = 1 32 | " let python_no_number_highlight = 1 33 | " let python_space_error_highlight = 1 34 | " 35 | " All the options above can be switched on together. 36 | " 37 | " let python_highlight_all = 1 38 | " 39 | 40 | " For version 5.x: Clear all syntax items. 41 | " For version 6.x: Quit when a syntax file was already loaded. 42 | if version < 600 43 | syntax clear 44 | elseif exists("b:current_syntax") 45 | finish 46 | endif 47 | 48 | " Keep Python keywords in alphabetical order inside groups for easy 49 | " comparison with the table in the 'Python Language Reference' 50 | " http://docs.python.org/reference/lexical_analysis.html#keywords. 51 | " Groups are in the order presented in NAMING CONVENTIONS in syntax.txt. 52 | " Exceptions come last at the end of each group (class and def below). 53 | " 54 | " Keywords 'with' and 'as' are new in Python 2.6 55 | " (use 'from __future__ import with_statement' in Python 2.5). 56 | " 57 | " Some compromises had to be made to support both Python 3.0 and 2.6. 58 | " We include Python 3.0 features, but when a definition is duplicated, 59 | " the last definition takes precedence. 60 | " 61 | " - 'False', 'None', and 'True' are keywords in Python 3.0 but they are 62 | " built-ins in 2.6 and will be highlighted as built-ins below. 63 | " - 'exec' is a built-in in Python 3.0 and will be highlighted as 64 | " built-in below. 65 | " - 'nonlocal' is a keyword in Python 3.0 and will be highlighted. 66 | " - 'print' is a built-in in Python 3.0 and will be highlighted as 67 | " built-in below (use 'from __future__ import print_function' in 2.6) 68 | " 69 | syn keyword pythonConstant False None True 70 | syn keyword pythonStatement as assert break continue del exec global 71 | syn keyword pythonStatement lambda nonlocal pass print return with yield 72 | syn keyword pythonStatement def nextgroup=pythonFunction skipwhite 73 | syn keyword pythonStatement class nextgroup=pythonClass skipwhite 74 | syn keyword pythonConditional elif else if 75 | syn keyword pythonRepeat for while 76 | syn keyword pythonOperator and in is not or 77 | syn keyword pythonException except finally raise try 78 | syn keyword pythonInclude from import 79 | 80 | " NOTE: @pfdevilliers added this 81 | " I copied this directly from the ruby.vim syntax file inorder to highlight all 82 | " the operators. This must offcourse be revised to only contain the operators 83 | " that exists in python. 84 | syn match pythonExtraOperator "\%([~!^&|*/%+-]\|\%(class\s*\)\@\|<=\|\%(<\|\>\|>=\|=\@\|\*\*\|\.\.\.\|\.\.\|::\|=\)" 85 | syn match pythonExtraPseudoOperator "\%(-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!=\)" 86 | 87 | 88 | "syn region pythonClass start="(" end=")" contains=pythonParameters skipwhite transparent 89 | " Decorators (new in Python 2.4) 90 | syn match pythonDecorator "@" display nextgroup=pythonFunction skipwhite 91 | " The zero-length non-grouping match before the function name is 92 | " extremely important in pythonFunction. Without it, everything is 93 | " interpreted as a function inside the contained environment of 94 | " doctests. 95 | " A dot must be allowed because of @MyClass.myfunc decorators. 96 | 97 | " NOTE: @pfdevilliers added this 98 | " This was added based on the guidelines from Stackoverflow. 99 | " http://stackoverflow.com/questions/8312132/vim-editing-the-python-vim-syntax-file-to-highlight-like-textmate 100 | " It is really a hack job ignoring best practices. I royally screwed up the 101 | " regular expressions which led to the definition of the pythonBrackets. 102 | " This should be improved and simplified. 103 | syn match pythonFunction 104 | \ "\%(\%(def\s\|class\s\|@\)\s*\)\@<=\h\%(\w\|\.\)*" contained nextgroup=pythonVars 105 | syn region pythonVars start="(" end=")" contained contains=pythonParameters transparent keepend 106 | syn match pythonParameters "[^,]*" contained contains=pythonParam,pythonBrackets skipwhite 107 | syn match pythonParam "=[^,]*" contained contains=pythonExtraOperator,pythonBuiltin,pythonConstant,pythonStatement,pythonNumber,pythonString skipwhite 108 | syn match pythonBrackets "[(|)]" contained skipwhite 109 | 110 | " NOTE: @pfdevilliers added this 111 | " The same as the previous definitions but for the python class. 112 | syn match pythonClass 113 | \ "\%(\%(def\s\|class\s\|@\)\s*\)\@<=\h\%(\w\|\.\)*" contained nextgroup=pythonClassVars 114 | syn region pythonClassVars start="(" end=")" contained contains=pythonClassParameters transparent keepend 115 | syn match pythonClassParameters "[^,]*" contained contains=pythonBuiltin,pythonBrackets skipwhite 116 | 117 | 118 | 119 | syn match pythonComment "#.*$" contains=pythonTodo,@Spell 120 | syn keyword pythonTodo FIXME NOTE NOTES TODO XXX contained 121 | 122 | " Triple-quoted strings can contain doctests. 123 | syn region pythonString 124 | \ start=+[uU]\=\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1" 125 | \ contains=pythonEscape,@Spell 126 | syn region pythonString 127 | \ start=+[uU]\=\z('''\|"""\)+ end="\z1" keepend 128 | \ contains=pythonEscape,pythonSpaceError,pythonDoctest,@Spell 129 | syn region pythonRawString 130 | \ start=+[uU]\=[rR]\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1" 131 | \ contains=@Spell 132 | syn region pythonRawString 133 | \ start=+[uU]\=[rR]\z('''\|"""\)+ end="\z1" keepend 134 | \ contains=pythonSpaceError,pythonDoctest,@Spell 135 | 136 | syn match pythonEscape +\\[abfnrtv'"\\]+ contained 137 | syn match pythonEscape "\\\o\{1,3}" contained 138 | syn match pythonEscape "\\x\x\{2}" contained 139 | syn match pythonEscape "\%(\\u\x\{4}\|\\U\x\{8}\)" contained 140 | " Python allows case-insensitive Unicode IDs: http://www.unicode.org/charts/ 141 | syn match pythonEscape "\\N{\a\+\%(\s\a\+\)*}" contained 142 | syn match pythonEscape "\\$" 143 | 144 | if exists("python_highlight_all") 145 | if exists("python_no_builtin_highlight") 146 | unlet python_no_builtin_highlight 147 | endif 148 | if exists("python_no_doctest_code_highlight") 149 | unlet python_no_doctest_code_highlight 150 | endif 151 | if exists("python_no_doctest_highlight") 152 | unlet python_no_doctest_highlight 153 | endif 154 | if exists("python_no_exception_highlight") 155 | unlet python_no_exception_highlight 156 | endif 157 | if exists("python_no_number_highlight") 158 | unlet python_no_number_highlight 159 | endif 160 | let python_space_error_highlight = 1 161 | endif 162 | 163 | " It is very important to understand all details before changing the 164 | " regular expressions below or their order. 165 | " The word boundaries are *not* the floating-point number boundaries 166 | " because of a possible leading or trailing decimal point. 167 | " The expressions below ensure that all valid number literals are 168 | " highlighted, and invalid number literals are not. For example, 169 | " 170 | " - a decimal point in '4.' at the end of a line is highlighted, 171 | " - a second dot in 1.0.0 is not highlighted, 172 | " - 08 is not highlighted, 173 | " - 08e0 or 08j are highlighted, 174 | " 175 | " and so on, as specified in the 'Python Language Reference'. 176 | " http://docs.python.org/reference/lexical_analysis.html#numeric-literals 177 | if !exists("python_no_number_highlight") 178 | " numbers (including longs and complex) 179 | syn match pythonNumber "\<0[oO]\=\o\+[Ll]\=\>" 180 | syn match pythonNumber "\<0[xX]\x\+[Ll]\=\>" 181 | syn match pythonNumber "\<0[bB][01]\+[Ll]\=\>" 182 | syn match pythonNumber "\<\%([1-9]\d*\|0\)[Ll]\=\>" 183 | syn match pythonNumber "\<\d\+[jJ]\>" 184 | syn match pythonNumber "\<\d\+[eE][+-]\=\d\+[jJ]\=\>" 185 | syn match pythonNumber 186 | \ "\<\d\+\.\%([eE][+-]\=\d\+\)\=[jJ]\=\%(\W\|$\)\@=" 187 | syn match pythonNumber 188 | \ "\%(^\|\W\)\@<=\d*\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>" 189 | endif 190 | 191 | " Group the built-ins in the order in the 'Python Library Reference' for 192 | " easier comparison. 193 | " http://docs.python.org/library/constants.html 194 | " http://docs.python.org/library/functions.html 195 | " http://docs.python.org/library/functions.html#non-essential-built-in-functions 196 | " Python built-in functions are in alphabetical order. 197 | if !exists("python_no_builtin_highlight") 198 | " built-in constants 199 | " 'False', 'True', and 'None' are also reserved words in Python 3.0 200 | syn keyword pythonConstant False True None 201 | syn keyword pythonConstant NotImplemented Ellipsis __debug__ 202 | " built-in functions 203 | syn keyword pythonBuiltin abs all any bin bool chr classmethod 204 | syn keyword pythonBuiltin compile complex delattr dict dir divmod 205 | syn keyword pythonBuiltin enumerate eval filter float format 206 | syn keyword pythonBuiltin frozenset getattr globals hasattr hash 207 | syn keyword pythonBuiltin help hex id input int isinstance 208 | syn keyword pythonBuiltin issubclass iter len list locals map max 209 | syn keyword pythonBuiltin min next object oct open ord pow print 210 | syn keyword pythonBuiltin property range repr reversed round set 211 | syn keyword pythonBuiltin setattr slice sorted staticmethod str 212 | syn keyword pythonBuiltin sum super tuple type vars zip __import__ 213 | " Python 2.6 only 214 | syn keyword pythonBuiltin basestring callable cmp execfile file 215 | syn keyword pythonBuiltin long raw_input reduce reload unichr 216 | syn keyword pythonBuiltin unicode xrange 217 | " Python 3.0 only 218 | syn keyword pythonBuiltin ascii bytearray bytes exec memoryview 219 | " non-essential built-in functions; Python 2.6 only 220 | syn keyword pythonBuiltin apply buffer coerce intern 221 | endif 222 | 223 | " From the 'Python Library Reference' class hierarchy at the bottom. 224 | " http://docs.python.org/library/exceptions.html 225 | if !exists("python_no_exception_highlight") 226 | " builtin base exceptions (only used as base classes for other exceptions) 227 | syn keyword pythonExceptions BaseException Exception 228 | syn keyword pythonExceptions ArithmeticError EnvironmentError 229 | syn keyword pythonExceptions LookupError 230 | " builtin base exception removed in Python 3.0 231 | syn keyword pythonExceptions StandardError 232 | " builtin exceptions (actually raised) 233 | syn keyword pythonExceptions AssertionError AttributeError BufferError 234 | syn keyword pythonExceptions EOFError FloatingPointError GeneratorExit 235 | syn keyword pythonExceptions IOError ImportError IndentationError 236 | syn keyword pythonExceptions IndexError KeyError KeyboardInterrupt 237 | syn keyword pythonExceptions MemoryError NameError NotImplementedError 238 | syn keyword pythonExceptions OSError OverflowError ReferenceError 239 | syn keyword pythonExceptions RuntimeError StopIteration SyntaxError 240 | syn keyword pythonExceptions SystemError SystemExit TabError TypeError 241 | syn keyword pythonExceptions UnboundLocalError UnicodeError 242 | syn keyword pythonExceptions UnicodeDecodeError UnicodeEncodeError 243 | syn keyword pythonExceptions UnicodeTranslateError ValueError VMSError 244 | syn keyword pythonExceptions WindowsError ZeroDivisionError 245 | " builtin warnings 246 | syn keyword pythonExceptions BytesWarning DeprecationWarning FutureWarning 247 | syn keyword pythonExceptions ImportWarning PendingDeprecationWarning 248 | syn keyword pythonExceptions RuntimeWarning SyntaxWarning UnicodeWarning 249 | syn keyword pythonExceptions UserWarning Warning 250 | endif 251 | 252 | if exists("python_space_error_highlight") 253 | " trailing whitespace 254 | syn match pythonSpaceError display excludenl "\s\+$" 255 | " mixed tabs and spaces 256 | syn match pythonSpaceError display " \+\t" 257 | syn match pythonSpaceError display "\t\+ " 258 | endif 259 | 260 | " Do not spell doctests inside strings. 261 | " Notice that the end of a string, either ''', or """, will end the contained 262 | " doctest too. Thus, we do *not* need to have it as an end pattern. 263 | if !exists("python_no_doctest_highlight") 264 | if !exists("python_no_doctest_code_higlight") 265 | syn region pythonDoctest 266 | \ start="^\s*>>>\s" end="^\s*$" 267 | \ contained contains=ALLBUT,pythonDoctest,@Spell 268 | syn region pythonDoctestValue 269 | \ start=+^\s*\%(>>>\s\|\.\.\.\s\|"""\|'''\)\@!\S\++ end="$" 270 | \ contained 271 | else 272 | syn region pythonDoctest 273 | \ start="^\s*>>>" end="^\s*$" 274 | \ contained contains=@NoSpell 275 | endif 276 | endif 277 | 278 | " Sync at the beginning of class, function, or method definition. 279 | syn sync match pythonSync grouphere NONE "^\s*\%(def\|class\)\s\+\h\w*\s*(" 280 | 281 | if version >= 508 || !exists("did_python_syn_inits") 282 | if version <= 508 283 | let did_python_syn_inits = 1 284 | command -nargs=+ HiLink hi link 285 | else 286 | command -nargs=+ HiLink hi def link 287 | endif 288 | 289 | " The default highlight links. Can be overridden later. 290 | " 291 | " NOTE: @pfdevilliers added this 292 | " I added some colors here but i'm not sure if it is the correct place to 293 | " override it. 294 | " 295 | " HiLink pythonStatement Statement 296 | HiLink pythonConstant Constant 297 | HiLink pythonStatement Structure 298 | HiLink pythonConditional Conditional 299 | HiLink pythonRepeat Repeat 300 | HiLink pythonOperator Operator 301 | HiLink pythonException Exception 302 | "HiLink pythonInclude Include 303 | HiLink pythonInclude Operator 304 | HiLink pythonDecorator Define 305 | HiLink pythonFunction Function 306 | HiLink pythonComment Comment 307 | HiLink pythonTodo Todo 308 | HiLink pythonString String 309 | HiLink pythonRawString String 310 | HiLink pythonEscape Special 311 | HiLink pythonExtraOperator Operator 312 | HiLink pythonExtraPseudoOperator Operator 313 | HiLink pythonClass Normal 314 | HiLink pythonParameters Identifier 315 | HiLink pythonParam Normal 316 | HiLink pythonBrackets Normal 317 | HiLink pythonClassParameters InheritUnderlined 318 | 319 | if !exists("python_no_number_highlight") 320 | HiLink pythonNumber Number 321 | endif 322 | if !exists("python_no_builtin_highlight") 323 | "HiLink pythonBuiltin Function 324 | HiLink pythonBuiltin Builtin 325 | endif 326 | if !exists("python_no_exception_highlight") 327 | HiLink pythonExceptions Structure 328 | endif 329 | if exists("python_space_error_highlight") 330 | HiLink pythonSpaceError Error 331 | endif 332 | if !exists("python_no_doctest_highlight") 333 | HiLink pythonDoctest Special 334 | HiLink pythonDoctestValue Define 335 | endif 336 | 337 | delcommand HiLink 338 | endif 339 | 340 | let b:current_syntax = "python" 341 | 342 | " vim:set sw=2 sts=2 ts=8 noet: 343 | --------------------------------------------------------------------------------