1" Vim syntax file 2" Language: Ruby 3" Maintainer: Doug Kearns <[email protected]> 4" URL: https://github.com/vim-ruby/vim-ruby 5" Release Coordinator: Doug Kearns <[email protected]> 6" ---------------------------------------------------------------------------- 7" 8" Previous Maintainer: Mirko Nasato 9" Thanks to perl.vim authors, and to Reimer Behrends. :-) (MN) 10" ---------------------------------------------------------------------------- 11 12" Prelude {{{1 13if exists("b:current_syntax") 14 finish 15endif 16 17" this file uses line continuations 18let s:cpo_sav = &cpo 19set cpo&vim 20 21" Folding Config {{{1 22if has("folding") && exists("ruby_fold") 23 setlocal foldmethod=syntax 24endif 25 26let s:foldable_groups = split( 27 \ get( 28 \ b:, 29 \ 'ruby_foldable_groups', 30 \ get(g:, 'ruby_foldable_groups', 'ALL') 31 \ ) 32 \ ) 33 34function! s:foldable(...) abort 35 if index(s:foldable_groups, 'ALL') > -1 36 return 1 37 endif 38 39 for l:i in a:000 40 if index(s:foldable_groups, l:i) > -1 41 return 1 42 endif 43 endfor 44 45 return 0 46endfunction " }}} 47 48syn cluster rubyNotTop contains=@rubyExtendedStringSpecial,@rubyRegexpSpecial,@rubyDeclaration,rubyConditional,rubyExceptional,rubyMethodExceptional,rubyTodo 49 50" Whitespace Errors {{{1 51if exists("ruby_space_errors") 52 if !exists("ruby_no_trail_space_error") 53 syn match rubySpaceError display excludenl "\s\+$" 54 endif 55 if !exists("ruby_no_tab_space_error") 56 syn match rubySpaceError display " \+\t"me=e-1 57 endif 58endif 59 60" Operators {{{1 61if exists("ruby_operators") 62 syn match rubyOperator "[~!^|*/%+-]\|&\.\@!\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|=\@1<!>\|\*\*\|\.\.\.\|\.\.\|::" 63 syn match rubyOperator "->\|-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!=" 64 syn region rubyBracketOperator matchgroup=rubyOperator start="\%(\w[?!]\=\|[]})]\)\@2<=\[\s*" end="\s*]" contains=ALLBUT,@rubyNotTop 65endif 66 67" Expression Substitution and Backslash Notation {{{1 68syn match rubyStringEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display 69syn match rubyStringEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display 70syn match rubyQuoteEscape "\\[\\']" contained display 71 72syn region rubyInterpolation matchgroup=rubyInterpolationDelimiter start="#{" end="}" contained contains=ALLBUT,@rubyNotTop 73syn match rubyInterpolation "#\%(\$\|@@\=\)\w\+" display contained contains=rubyInterpolationDelimiter,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable,rubyPredefinedVariable 74syn match rubyInterpolationDelimiter "#\ze\%(\$\|@@\=\)\w\+" display contained 75syn match rubyInterpolation "#\$\%(-\w\|\W\)" display contained contains=rubyInterpolationDelimiter,rubyPredefinedVariable,rubyInvalidVariable 76syn match rubyInterpolationDelimiter "#\ze\$\%(-\w\|\W\)" display contained 77syn region rubyNoInterpolation start="\\#{" end="}" contained 78syn match rubyNoInterpolation "\\#{" display contained 79syn match rubyNoInterpolation "\\#\%(\$\|@@\=\)\w\+" display contained 80syn match rubyNoInterpolation "\\#\$\W" display contained 81 82syn match rubyDelimiterEscape "\\[(<{\[)>}\]]" transparent display contained contains=NONE 83 84syn region rubyNestedParentheses start="(" skip="\\\\\|\\)" matchgroup=rubyString end=")" transparent contained 85syn region rubyNestedCurlyBraces start="{" skip="\\\\\|\\}" matchgroup=rubyString end="}" transparent contained 86syn region rubyNestedAngleBrackets start="<" skip="\\\\\|\\>" matchgroup=rubyString end=">" transparent contained 87syn region rubyNestedSquareBrackets start="\[" skip="\\\\\|\\\]" matchgroup=rubyString end="\]" transparent contained 88 89" Regular Expression Metacharacters {{{1 90" These are mostly Oniguruma ready 91syn region rubyRegexpComment matchgroup=rubyRegexpSpecial start="(?#" skip="\\)" end=")" contained 92syn region rubyRegexpParens matchgroup=rubyRegexpSpecial start="(\(?:\|?<\=[=!]\|?>\|?<[a-z_]\w*>\|?[imx]*-[imx]*:\=\|\%(?#\)\@!\)" skip="\\)" end=")" contained transparent contains=@rubyRegexpSpecial 93syn region rubyRegexpBrackets matchgroup=rubyRegexpCharClass start="\[\^\=" skip="\\\]" end="\]" contained transparent contains=rubyStringEscape,rubyRegexpEscape,rubyRegexpCharClass oneline 94syn match rubyRegexpCharClass "\\[DdHhSsWw]" contained display 95syn match rubyRegexpCharClass "\[:\^\=\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|xdigit\):\]" contained 96syn match rubyRegexpEscape "\\[].*?+^$|\\/(){}[]" contained 97syn match rubyRegexpQuantifier "[*?+][?+]\=" contained display 98syn match rubyRegexpQuantifier "{\d\+\%(,\d*\)\=}?\=" contained display 99syn match rubyRegexpAnchor "[$^]\|\\[ABbGZz]" contained display 100syn match rubyRegexpDot "\." contained display 101syn match rubyRegexpSpecial "|" contained display 102syn match rubyRegexpSpecial "\\[1-9]\d\=\d\@!" contained display 103syn match rubyRegexpSpecial "\\k<\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\=>" contained display 104syn match rubyRegexpSpecial "\\k'\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\='" contained display 105syn match rubyRegexpSpecial "\\g<\%([a-z_]\w*\|-\=\d\+\)>" contained display 106syn match rubyRegexpSpecial "\\g'\%([a-z_]\w*\|-\=\d\+\)'" contained display 107 108syn cluster rubyStringSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyStringEscape 109syn cluster rubyExtendedStringSpecial contains=@rubyStringSpecial,rubyNestedParentheses,rubyNestedCurlyBraces,rubyNestedAngleBrackets,rubyNestedSquareBrackets 110syn cluster rubyRegexpSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyStringEscape,rubyRegexpSpecial,rubyRegexpEscape,rubyRegexpBrackets,rubyRegexpCharClass,rubyRegexpDot,rubyRegexpQuantifier,rubyRegexpAnchor,rubyRegexpParens,rubyRegexpComment 111 112" Numbers and ASCII Codes {{{1 113syn match rubyASCIICode "\%(\w\|[]})\"'/]\)\@1<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)\)" 114syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[xX]\x\+\%(_\x\+\)*r\=i\=\>" display 115syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0[dD]\)\=\%(0\|[1-9]\d*\%(_\d\+\)*\)r\=i\=\>" display 116syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[oO]\=\o\+\%(_\o\+\)*r\=i\=\>" display 117syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[bB][01]\+\%(_[01]\+\)*r\=i\=\>" display 118syn match rubyFloat "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\.\d\+\%(_\d\+\)*r\=i\=\>" display 119syn match rubyFloat "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\%(\.\d\+\%(_\d\+\)*\)\=\%([eE][-+]\=\d\+\%(_\d\+\)*\)r\=i\=\>" display 120 121" Identifiers {{{1 122syn match rubyLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent 123syn match rubyBlockArgument "&[_[:lower:]][_[:alnum:]]" contains=NONE display transparent 124 125syn match rubyConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@!" 126syn match rubyClassVariable "@@\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" display 127syn match rubyInstanceVariable "@\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" display 128syn match rubyGlobalVariable "$\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\|-.\)" 129syn match rubySymbol "[]})\"':]\@1<!:\%(\^\|\~@\|\~\|<<\|<=>\|<=\|<\|===\|[=!]=\|[=!]\~\|!@\|!\|>>\|>=\|>\||\|-@\|-\|/\|\[]=\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)" 130syn match rubySymbol "[]})\"':]\@1<!:\$\%(-.\|[`~<=>_,;:!?/.'"@$*\&+0]\)" 131syn match rubySymbol "[]})\"':]\@1<!:\%(\$\|@@\=\)\=\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" 132syn match rubySymbol "[]})\"':]\@1<!:\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\%([?!=]>\@!\)\=" 133 134if s:foldable(':') 135 syn region rubySymbol start="[]})\"':]\@1<!:'" end="'" skip="\\\\\|\\'" contains=rubyQuoteEscape fold 136 syn region rubySymbol start="[]})\"':]\@1<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold 137else 138 syn region rubySymbol start="[]})\"':]\@1<!:'" end="'" skip="\\\\\|\\'" contains=rubyQuoteEscape 139 syn region rubySymbol start="[]})\"':]\@1<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial 140endif 141 142syn match rubyCapitalizedMethod "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)*\s*(\@=" 143 144syn match rubyBlockParameter "\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" contained 145syn region rubyBlockParameterList start="\%(\%(\<do\>\|{\)\_s*\)\@32<=|" end="|" oneline display contains=rubyBlockParameter 146 147syn match rubyInvalidVariable "$[^ A-Za-z_-]" 148syn match rubyPredefinedVariable #$[!$&"'*+,./0:;<=>?@\`~]# 149syn match rubyPredefinedVariable "$\d\+" display 150syn match rubyPredefinedVariable "$_\>" display 151syn match rubyPredefinedVariable "$-[0FIKadilpvw]\>" display 152syn match rubyPredefinedVariable "$\%(deferr\|defout\|stderr\|stdin\|stdout\)\>" display 153syn match rubyPredefinedVariable "$\%(DEBUG\|FILENAME\|KCODE\|LOADED_FEATURES\|LOAD_PATH\|PROGRAM_NAME\|SAFE\|VERBOSE\)\>" display 154syn match rubyPredefinedConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\%(ARGF\|ARGV\|ENV\|DATA\|FALSE\|NIL\|STDERR\|STDIN\|STDOUT\|TOPLEVEL_BINDING\|TRUE\)\>\%(\s*(\)\@!" 155syn match rubyPredefinedConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\%(RUBY_\%(VERSION\|RELEASE_DATE\|PLATFORM\|PATCHLEVEL\|REVISION\|DESCRIPTION\|COPYRIGHT\|ENGINE\)\)\>\%(\s*(\)\@!" 156 157" Normal Regular Expression {{{1 158if s:foldable('/') 159 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,{[<>?:*+-]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold 160 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/[ \t=]\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold 161else 162 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,{[<>?:*+-]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial 163 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/[ \t=]\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial 164endif 165 166" Generalized Regular Expression {{{1 167if s:foldable('%') 168 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial fold 169 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyRegexpSpecial fold 170 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyRegexpSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape fold 171 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyRegexpSpecial fold 172 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyRegexpSpecial fold 173 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z(\s\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial fold 174else 175 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial 176 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyRegexpSpecial 177 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyRegexpSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape 178 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyRegexpSpecial 179 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyRegexpSpecial 180 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z(\s\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial 181endif 182 183" Normal String {{{1 184let s:spell_cluster = exists('ruby_spellcheck_strings') ? ',@Spell' : '' 185exe 'syn region rubyString matchgroup=rubyStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" ' . 186 \ (s:foldable('%') ? 'fold' : '') . ' contains=@rubyStringSpecial' . s:spell_cluster 187exe 'syn region rubyString matchgroup=rubyStringDelimiter start="''" end="''" skip="\\\\\|\\''" ' . 188 \ (s:foldable('%') ? 'fold' : '') . ' contains=rubyQuoteEscape' . s:spell_cluster 189 190" Shell Command Output {{{1 191if s:foldable('%') 192 syn region rubyString matchgroup=rubyStringDelimiter start="`" end="`" skip="\\\\\|\\`" contains=@rubyStringSpecial fold 193else 194 syn region rubyString matchgroup=rubyStringDelimiter start="`" end="`" skip="\\\\\|\\`" contains=@rubyStringSpecial 195endif 196 197" Generalized Single Quoted String, Symbol and Array of Strings {{{1 198if s:foldable('%') 199 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold 200 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimiterEscape 201 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimiterEscape 202 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimiterEscape 203 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw](" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimiterEscape 204 syn region rubyString matchgroup=rubyStringDelimiter start="%q\z(\s\)" end="\z1" skip="\\\\\|\\\z1" fold 205 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold 206 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimiterEscape 207 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimiterEscape 208 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimiterEscape 209 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s(" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimiterEscape 210 syn region rubyString matchgroup=rubyStringDelimiter start="%s\z(\s\)" end="\z1" skip="\\\\\|\\\z1" fold 211else 212 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" 213 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]{" end="}" skip="\\\\\|\\}" contains=rubyNestedCurlyBraces,rubyDelimiterEscape 214 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]<" end=">" skip="\\\\\|\\>" contains=rubyNestedAngleBrackets,rubyDelimiterEscape 215 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\[" end="\]" skip="\\\\\|\\\]" contains=rubyNestedSquareBrackets,rubyDelimiterEscape 216 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw](" end=")" skip="\\\\\|\\)" contains=rubyNestedParentheses,rubyDelimiterEscape 217 syn region rubyString matchgroup=rubyStringDelimiter start="%q\z(\s\)" end="\z1" skip="\\\\\|\\\z1" 218 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" 219 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s{" end="}" skip="\\\\\|\\}" contains=rubyNestedCurlyBraces,rubyDelimiterEscape 220 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s<" end=">" skip="\\\\\|\\>" contains=rubyNestedAngleBrackets,rubyDelimiterEscape 221 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\[" end="\]" skip="\\\\\|\\\]" contains=rubyNestedSquareBrackets,rubyDelimiterEscape 222 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s(" end=")" skip="\\\\\|\\)" contains=rubyNestedParentheses,rubyDelimiterEscape 223 syn region rubyString matchgroup=rubyStringDelimiter start="%s\z(\s\)" end="\z1" skip="\\\\\|\\\z1" 224endif 225 226" Generalized Double Quoted String and Array of Strings and Shell Command Output {{{1 227" Note: %= is not matched here as the beginning of a double quoted string 228if s:foldable('%') 229 syn region rubyString matchgroup=rubyStringDelimiter start="%\z([~`!@#$%^&*_\-+|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold 230 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold 231 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\={" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimiterEscape fold 232 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape fold 233 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape fold 234 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape fold 235 syn region rubyString matchgroup=rubyStringDelimiter start="%[Qx]\z(\s\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold 236else 237 syn region rubyString matchgroup=rubyStringDelimiter start="%\z([~`!@#$%^&*_\-+|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial 238 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial 239 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\={" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimiterEscape 240 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape 241 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape 242 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape 243 syn region rubyString matchgroup=rubyStringDelimiter start="%[Qx]\z(\s\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial 244endif 245 246" Array of Symbols {{{1 247if s:foldable('%') 248 " Array of Symbols 249 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold 250 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimiterEscape 251 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimiterEscape 252 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimiterEscape 253 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i(" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimiterEscape 254 255 " Array of interpolated Symbols 256 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold 257 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I{" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimiterEscape fold 258 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape fold 259 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape fold 260 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape fold 261else 262 " Array of Symbols 263 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" 264 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i{" end="}" skip="\\\\\|\\}" contains=rubyNestedCurlyBraces,rubyDelimiterEscape 265 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i<" end=">" skip="\\\\\|\\>" contains=rubyNestedAngleBrackets,rubyDelimiterEscape 266 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\[" end="\]" skip="\\\\\|\\\]" contains=rubyNestedSquareBrackets,rubyDelimiterEscape 267 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i(" end=")" skip="\\\\\|\\)" contains=rubyNestedParentheses,rubyDelimiterEscape 268 269 " Array of interpolated Symbols 270 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial 271 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I{" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimiterEscape 272 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape 273 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape 274 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape 275endif 276 277" Here Document {{{1 278syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<[-~]\=\zs\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)+ end=+$+ oneline contains=ALLBUT,@rubyNotTop 279syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<[-~]\=\zs"\%([^"]*\)"+ end=+$+ oneline contains=ALLBUT,@rubyNotTop 280syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<[-~]\=\zs'\%([^']*\)'+ end=+$+ oneline contains=ALLBUT,@rubyNotTop 281syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<[-~]\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=ALLBUT,@rubyNotTop 282 283if s:foldable('<<') 284 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend 285 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend 286 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc fold keepend 287 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend 288 289 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend 290 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend 291 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart fold keepend 292 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend 293else 294 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial keepend 295 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial keepend 296 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc keepend 297 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial keepend 298 299 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial keepend 300 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial keepend 301 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart keepend 302 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial keepend 303endif 304 305" eRuby Config {{{1 306if exists('main_syntax') && main_syntax == 'eruby' 307 let b:ruby_no_expensive = 1 308end 309 310" Module, Class, Method and Alias Declarations {{{1 311syn match rubyAliasDeclaration "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable nextgroup=rubyAliasDeclaration2 skipwhite 312syn match rubyAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable 313syn match rubyMethodDeclaration "[^[:space:];#(]\+" contained contains=rubyConstant,rubyBoolean,rubyPseudoVariable,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable 314syn match rubyClassDeclaration "[^[:space:];#<]\+" contained contains=rubyConstant,rubyOperator 315syn match rubyModuleDeclaration "[^[:space:];#<]\+" contained contains=rubyConstant,rubyOperator 316syn match rubyFunction "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:]_.:?!=]\@!" contained containedin=rubyMethodDeclaration 317syn match rubyFunction "\%(\s\|^\)\@1<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2 318syn match rubyFunction "\%([[:space:].]\|^\)\@2<=\%(\[\]=\=\|\*\*\|[-+!~]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration 319 320syn cluster rubyDeclaration contains=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration,rubyModuleDeclaration,rubyClassDeclaration,rubyFunction,rubyBlockParameter 321 322" Keywords {{{1 323" Note: the following keywords have already been defined: 324" begin case class def do end for if module unless until while 325syn match rubyControl "\<\%(and\|break\|in\|next\|not\|or\|redo\|rescue\|retry\|return\)\>[?!]\@!" 326syn match rubyOperator "\<defined?" display 327syn match rubyKeyword "\<\%(super\|yield\)\>[?!]\@!" 328syn match rubyBoolean "\<\%(true\|false\)\>[?!]\@!" 329syn match rubyPseudoVariable "\<\%(nil\|self\|__ENCODING__\|__dir__\|__FILE__\|__LINE__\|__callee__\|__method__\)\>[?!]\@!" " TODO: reorganise 330syn match rubyBeginEnd "\<\%(BEGIN\|END\)\>[?!]\@!" 331 332" Expensive Mode {{{1 333" Match 'end' with the appropriate opening keyword for syntax based folding 334" and special highlighting of module/class/method definitions 335if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive") 336 syn match rubyDefine "\<alias\>" nextgroup=rubyAliasDeclaration skipwhite skipnl 337 syn match rubyDefine "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl 338 syn match rubyDefine "\<undef\>" nextgroup=rubyFunction skipwhite skipnl 339 syn match rubyClass "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl 340 syn match rubyModule "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl 341 342 if s:foldable('def') 343 syn region rubyMethodBlock start="\<def\>" matchgroup=rubyDefine end="\%(\<def\_s\+\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop fold 344 else 345 syn region rubyMethodBlock start="\<def\>" matchgroup=rubyDefine end="\%(\<def\_s\+\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop 346 endif 347 348 if s:foldable('class') 349 syn region rubyBlock start="\<class\>" matchgroup=rubyClass end="\<end\>" contains=ALLBUT,@rubyNotTop fold 350 else 351 syn region rubyBlock start="\<class\>" matchgroup=rubyClass end="\<end\>" contains=ALLBUT,@rubyNotTop 352 endif 353 354 if s:foldable('module') 355 syn region rubyBlock start="\<module\>" matchgroup=rubyModule end="\<end\>" contains=ALLBUT,@rubyNotTop fold 356 else 357 syn region rubyBlock start="\<module\>" matchgroup=rubyModule end="\<end\>" contains=ALLBUT,@rubyNotTop 358 endif 359 360 " modifiers 361 syn match rubyLineContinuation "\\$" nextgroup=rubyConditionalModifier,rubyRepeatModifier skipwhite skipnl 362 syn match rubyConditionalModifier "\<\%(if\|unless\)\>" 363 syn match rubyRepeatModifier "\<\%(while\|until\)\>" 364 365 if s:foldable('do') 366 syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold 367 else 368 syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=ALLBUT,@rubyNotTop 369 endif 370 371 " curly bracket block or hash literal 372 if s:foldable('{') 373 syn region rubyCurlyBlock matchgroup=rubyCurlyBlockDelimiter start="{" end="}" contains=ALLBUT,@rubyNotTop fold 374 else 375 syn region rubyCurlyBlock matchgroup=rubyCurlyBlockDelimiter start="{" end="}" contains=ALLBUT,@rubyNotTop 376 endif 377 378 if s:foldable('[') 379 syn region rubyArrayLiteral matchgroup=rubyArrayDelimiter start="\%(\w\|[\]})]\)\@<!\[" end="]" contains=ALLBUT,@rubyNotTop fold 380 else 381 syn region rubyArrayLiteral matchgroup=rubyArrayDelimiter start="\%(\w\|[\]})]\)\@<!\[" end="]" contains=ALLBUT,@rubyNotTop 382 endif 383 384 " statements without 'do' 385 if s:foldable('begin') 386 syn region rubyBlockExpression matchgroup=rubyControl start="\<begin\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold 387 else 388 syn region rubyBlockExpression matchgroup=rubyControl start="\<begin\>" end="\<end\>" contains=ALLBUT,@rubyNotTop 389 endif 390 391 if s:foldable('case') 392 syn region rubyCaseExpression matchgroup=rubyConditional start="\<case\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold 393 else 394 syn region rubyCaseExpression matchgroup=rubyConditional start="\<case\>" end="\<end\>" contains=ALLBUT,@rubyNotTop 395 endif 396 397 if s:foldable('if') 398 syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![?!]\)\s*\)\@<=\%(if\|unless\)\>" end="\%(\%(\%(\.\@1<!\.\)\|::\)\s*\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop fold 399 else 400 syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![?!]\)\s*\)\@<=\%(if\|unless\)\>" end="\%(\%(\%(\.\@1<!\.\)\|::\)\s*\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop 401 endif 402 403 syn match rubyConditional "\<\%(then\|else\|when\)\>[?!]\@!" contained containedin=rubyCaseExpression 404 syn match rubyConditional "\<\%(then\|else\|elsif\)\>[?!]\@!" contained containedin=rubyConditionalExpression 405 406 syn match rubyExceptional "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=rubyBlockExpression 407 syn match rubyMethodExceptional "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=rubyMethodBlock 408 409 " statements with optional 'do' 410 syn region rubyOptionalDoLine matchgroup=rubyRepeat start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyOptionalDo end="\%(\<do\>\)" end="\ze\%(;\|$\)" oneline contains=ALLBUT,@rubyNotTop 411 412 if s:foldable('for') 413 syn region rubyRepeatExpression start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat end="\<end\>" contains=ALLBUT,@rubyNotTop nextgroup=rubyOptionalDoLine fold 414 else 415 syn region rubyRepeatExpression start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat end="\<end\>" contains=ALLBUT,@rubyNotTop nextgroup=rubyOptionalDoLine 416 endif 417 418 if !exists("ruby_minlines") 419 let ruby_minlines = 500 420 endif 421 exec "syn sync minlines=" . ruby_minlines 422 423else 424 syn match rubyControl "\<def\>[?!]\@!" nextgroup=rubyMethodDeclaration skipwhite skipnl 425 syn match rubyControl "\<class\>[?!]\@!" nextgroup=rubyClassDeclaration skipwhite skipnl 426 syn match rubyControl "\<module\>[?!]\@!" nextgroup=rubyModuleDeclaration skipwhite skipnl 427 syn match rubyControl "\<\%(case\|begin\|do\|for\|if\|unless\|while\|until\|else\|elsif\|ensure\|then\|when\|end\)\>[?!]\@!" 428 syn match rubyKeyword "\<\%(alias\|undef\)\>[?!]\@!" 429endif 430 431" Special Methods {{{1 432if !exists("ruby_no_special_methods") 433 syn keyword rubyAccess public protected private public_class_method private_class_method public_constant private_constant module_function 434 " attr is a common variable name 435 syn match rubyAttribute "\%(\%(^\|;\)\s*\)\@<=attr\>\(\s*[.=]\)\@!" 436 syn keyword rubyAttribute attr_accessor attr_reader attr_writer 437 syn match rubyControl "\<\%(exit!\|\%(abort\|at_exit\|exit\|fork\|loop\|trap\)\>[?!]\@!\)" 438 syn keyword rubyEval eval class_eval instance_eval module_eval 439 syn keyword rubyException raise fail catch throw 440 " false positive with 'include?' 441 syn match rubyInclude "\<include\>[?!]\@!" 442 syn keyword rubyInclude autoload extend load prepend refine require require_relative using 443 syn keyword rubyKeyword callcc caller lambda proc 444endif 445 446" Comments and Documentation {{{1 447syn match rubySharpBang "\%^#!.*" display 448syn keyword rubyTodo FIXME NOTE TODO OPTIMIZE HACK REVIEW XXX todo contained 449syn match rubyComment "#.*" contains=rubySharpBang,rubySpaceError,rubyTodo,@Spell 450if !exists("ruby_no_comment_fold") && s:foldable('#') 451 syn region rubyMultilineComment start="^\s*#.*\n\%(^\s*#\)\@=" end="^\s*#.*\n\%(^\s*#\)\@!" contains=rubyComment transparent fold keepend 452 syn region rubyDocumentation start="^=begin\ze\%(\s.*\)\=$" end="^=end\%(\s.*\)\=$" contains=rubySpaceError,rubyTodo,@Spell fold 453else 454 syn region rubyDocumentation start="^=begin\s*$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell 455endif 456 457" Keyword Nobbling {{{1 458" Note: this is a hack to prevent 'keywords' being highlighted as such when called as methods with an explicit receiver 459syn match rubyKeywordAsMethod "\%(\%(\.\@1<!\.\)\|::\)\_s*\%([_[:lower:]][_[:alnum:]]*\|\<\%(BEGIN\|END\)\>\)" transparent contains=NONE 460syn match rubyKeywordAsMethod "\(defined?\|exit!\)\@!\<[_[:lower:]][_[:alnum:]]*[?!]" transparent contains=NONE 461 462" More Symbols {{{1 463syn match rubySymbol "\%([{(,]\_s*\)\zs\l\w*[!?]\=::\@!"he=e-1 464syn match rubySymbol "[]})\"':]\@1<!\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],]\@="he=e-1 465syn match rubySymbol "\%([{(,]\_s*\)\zs[[:space:],{]\l\w*[!?]\=::\@!"hs=s+1,he=e-1 466syn match rubySymbol "[[:space:],{(]\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],]\@="hs=s+1,he=e-1 467 468" __END__ Directive {{{1 469if s:foldable('__END__') 470 syn region rubyData matchgroup=rubyDataDirective start="^__END__$" end="\%$" fold 471else 472 syn region rubyData matchgroup=rubyDataDirective start="^__END__$" end="\%$" 473endif 474 475" Default Highlighting {{{1 476hi def link rubyClass rubyDefine 477hi def link rubyModule rubyDefine 478hi def link rubyMethodExceptional rubyDefine 479hi def link rubyDefine Define 480hi def link rubyFunction Function 481hi def link rubyConditional Conditional 482hi def link rubyConditionalModifier rubyConditional 483hi def link rubyExceptional rubyConditional 484hi def link rubyRepeat Repeat 485hi def link rubyRepeatModifier rubyRepeat 486hi def link rubyOptionalDo rubyRepeat 487hi def link rubyControl Statement 488hi def link rubyInclude Include 489hi def link rubyInteger Number 490hi def link rubyASCIICode Character 491hi def link rubyFloat Float 492hi def link rubyBoolean Boolean 493hi def link rubyException Exception 494if !exists("ruby_no_identifiers") 495 hi def link rubyIdentifier Identifier 496else 497 hi def link rubyIdentifier NONE 498endif 499hi def link rubyClassVariable rubyIdentifier 500hi def link rubyConstant Type 501hi def link rubyGlobalVariable rubyIdentifier 502hi def link rubyBlockParameter rubyIdentifier 503hi def link rubyInstanceVariable rubyIdentifier 504hi def link rubyPredefinedIdentifier rubyIdentifier 505hi def link rubyPredefinedConstant rubyPredefinedIdentifier 506hi def link rubyPredefinedVariable rubyPredefinedIdentifier 507hi def link rubySymbol Constant 508hi def link rubyKeyword Keyword 509hi def link rubyOperator Operator 510hi def link rubyBeginEnd Statement 511hi def link rubyAccess Statement 512hi def link rubyAttribute Statement 513hi def link rubyEval Statement 514hi def link rubyPseudoVariable Constant 515hi def link rubyCapitalizedMethod rubyLocalVariableOrMethod 516 517hi def link rubyComment Comment 518hi def link rubyData Comment 519hi def link rubyDataDirective Delimiter 520hi def link rubyDocumentation Comment 521hi def link rubyTodo Todo 522 523hi def link rubyQuoteEscape rubyStringEscape 524hi def link rubyStringEscape Special 525hi def link rubyInterpolationDelimiter Delimiter 526hi def link rubyNoInterpolation rubyString 527hi def link rubySharpBang PreProc 528hi def link rubyRegexpDelimiter rubyStringDelimiter 529hi def link rubySymbolDelimiter rubySymbol 530hi def link rubyStringDelimiter Delimiter 531hi def link rubyHeredoc rubyString 532hi def link rubyString String 533hi def link rubyRegexpEscape rubyRegexpSpecial 534hi def link rubyRegexpQuantifier rubyRegexpSpecial 535hi def link rubyRegexpAnchor rubyRegexpSpecial 536hi def link rubyRegexpDot rubyRegexpCharClass 537hi def link rubyRegexpCharClass rubyRegexpSpecial 538hi def link rubyRegexpSpecial Special 539hi def link rubyRegexpComment Comment 540hi def link rubyRegexp rubyString 541 542hi def link rubyInvalidVariable Error 543hi def link rubyError Error 544hi def link rubySpaceError rubyError 545 546" Postscript {{{1 547let b:current_syntax = "ruby" 548 549let &cpo = s:cpo_sav 550unlet! s:cpo_sav 551 552" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: 553