1071d4279SBram Moolenaar" Vim syntax file 2071d4279SBram Moolenaar" Language: Ruby 3c6249bb2SBram Moolenaar" Maintainer: Doug Kearns <[email protected]> 46b730e11SBram Moolenaar" Info: $Id$ 5a5792f58SBram Moolenaar" URL: http://vim-ruby.rubyforge.org 66b730e11SBram Moolenaar" Anon CVS: See above site 7c6249bb2SBram Moolenaar" Release Coordinator: Doug Kearns <[email protected]> 86b730e11SBram Moolenaar" ---------------------------------------------------------------------------- 96b730e11SBram Moolenaar" 10071d4279SBram Moolenaar" Previous Maintainer: Mirko Nasato 11071d4279SBram Moolenaar" Thanks to perl.vim authors, and to Reimer Behrends. :-) (MN) 126b730e11SBram Moolenaar" ---------------------------------------------------------------------------- 13071d4279SBram Moolenaar 14*c1762ccbSBram Moolenaarif exists("b:current_syntax") 15071d4279SBram Moolenaar finish 16071d4279SBram Moolenaarendif 17071d4279SBram Moolenaar 186b730e11SBram Moolenaarif has("folding") && exists("ruby_fold") 196b730e11SBram Moolenaar setlocal foldmethod=syntax 206b730e11SBram Moolenaarendif 216b730e11SBram Moolenaar 226b730e11SBram Moolenaarif exists("ruby_space_errors") 236b730e11SBram Moolenaar if !exists("ruby_no_trail_space_error") 246b730e11SBram Moolenaar syn match rubySpaceError display excludenl "\s\+$" 256b730e11SBram Moolenaar endif 266b730e11SBram Moolenaar if !exists("ruby_no_tab_space_error") 276b730e11SBram Moolenaar syn match rubySpaceError display " \+\t"me=e-1 286b730e11SBram Moolenaar endif 296b730e11SBram Moolenaarendif 306b730e11SBram Moolenaar 319964e468SBram Moolenaar" Operators 329964e468SBram Moolenaarif exists("ruby_operators") 33*c1762ccbSBram Moolenaar syn match rubyOperator "\%([~!^&|*/%+-]\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|=\@<!>\|\*\*\|\.\.\.\|\.\.\|::\)" 34*c1762ccbSBram Moolenaar syn match rubyPseudoOperator "\%(-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!=\)" 35*c1762ccbSBram Moolenaar syn region rubyBracketOperator matchgroup=rubyOperator start="\%([_[:lower:]]\w*[?!=]\=\|[})]\)\@<=\[\s*" end="\s*]" contains=TOP 369964e468SBram Moolenaarendif 379964e468SBram Moolenaar 38071d4279SBram Moolenaar" Expression Substitution and Backslash Notation 396b730e11SBram Moolenaarsyn match rubyEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display 406b730e11SBram Moolenaarsyn match rubyEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display 419964e468SBram Moolenaar 429964e468SBram Moolenaarsyn region rubyInterpolation matchgroup=rubyInterpolationDelimiter start="#{" end="}" contained contains=TOP 439964e468SBram Moolenaarsyn match rubyInterpolation "#\%(\$\|@@\=\)\w\+" display contained contains=rubyInterpolationDelimiter,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable,rubyPredefinedVariable 449964e468SBram Moolenaarsyn match rubyInterpolationDelimiter "#\ze\%(\$\|@@\=\)\w\+" display contained 45*c1762ccbSBram Moolenaarsyn match rubyInterpolation "#\$\%(-\w\|\W\)" display contained contains=rubyInterpolationDelimiter,rubyPredefinedVariable,rubyInvalidVariable 46*c1762ccbSBram Moolenaarsyn match rubyInterpolationDelimiter "#\ze\$\%(-\w\|\W\)" display contained 479964e468SBram Moolenaarsyn region rubyNoInterpolation start="\\#{" end="}" contained 489964e468SBram Moolenaarsyn match rubyNoInterpolation "\\#{" display contained 499964e468SBram Moolenaarsyn match rubyNoInterpolation "\\#\%(\$\|@@\=\)\w\+" display contained 50*c1762ccbSBram Moolenaarsyn match rubyNoInterpolation "\\#\$\W" display contained 516b730e11SBram Moolenaar 526b730e11SBram Moolenaarsyn match rubyDelimEscape "\\[(<{\[)>}\]]" transparent display contained contains=NONE 536b730e11SBram Moolenaar 546b730e11SBram Moolenaarsyn region rubyNestedParentheses start="(" end=")" skip="\\\\\|\\)" transparent contained contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape 556b730e11SBram Moolenaarsyn region rubyNestedCurlyBraces start="{" end="}" skip="\\\\\|\\}" transparent contained contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimEscape 566b730e11SBram Moolenaarsyn region rubyNestedAngleBrackets start="<" end=">" skip="\\\\\|\\>" transparent contained contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimEscape 57*c1762ccbSBram Moolenaarif exists("ruby_operators") 586b730e11SBram Moolenaar syn region rubyNestedSquareBrackets start="\[" end="\]" skip="\\\\\|\\\]" transparent contained contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape 59*c1762ccbSBram Moolenaarelse 60*c1762ccbSBram Moolenaar syn region rubyNestedSquareBrackets start="\[" end="\]" skip="\\\\\|\\\]" transparent containedin=rubyArrayLiteral contained contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape 61*c1762ccbSBram Moolenaarendif 626b730e11SBram Moolenaar 636b730e11SBram Moolenaarsyn cluster rubyStringSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyEscape 646b730e11SBram Moolenaarsyn cluster rubyExtendedStringSpecial contains=@rubyStringSpecial,rubyNestedParentheses,rubyNestedCurlyBraces,rubyNestedAngleBrackets,rubyNestedSquareBrackets 65071d4279SBram Moolenaar 66071d4279SBram Moolenaar" Numbers and ASCII Codes 67*c1762ccbSBram Moolenaarsyn match rubyASCIICode "\%(\w\|[]})\"'/]\)\@<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)\)" 686b730e11SBram Moolenaarsyn match rubyInteger "\<0[xX]\x\+\%(_\x\+\)*\>" display 696b730e11SBram Moolenaarsyn match rubyInteger "\<\%(0[dD]\)\=\%(0\|[1-9]\d*\%(_\d\+\)*\)\>" display 706b730e11SBram Moolenaarsyn match rubyInteger "\<0[oO]\=\o\+\%(_\o\+\)*\>" display 716b730e11SBram Moolenaarsyn match rubyInteger "\<0[bB][01]\+\%(_[01]\+\)*\>" display 726b730e11SBram Moolenaarsyn match rubyFloat "\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\.\d\+\%(_\d\+\)*\>" display 736b730e11SBram Moolenaarsyn match rubyFloat "\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\%(\.\d\+\%(_\d\+\)*\)\=\%([eE][-+]\=\d\+\%(_\d\+\)*\)\>" display 74071d4279SBram Moolenaar 756b730e11SBram Moolenaar" Identifiers 766b730e11SBram Moolenaarsyn match rubyLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent 776b730e11SBram Moolenaarsyn match rubyBlockArgument "&[_[:lower:]][_[:alnum:]]" contains=NONE display transparent 78071d4279SBram Moolenaar 799964e468SBram Moolenaarsyn match rubyConstant "\%(\%([.@$]\@<!\.\)\@<!\<\|::\)\_s*\zs\u\w*\%(\>\|::\)\@=\%(\s*(\)\@!" 806b730e11SBram Moolenaarsyn match rubyClassVariable "@@\h\w*" display 816b730e11SBram Moolenaarsyn match rubyInstanceVariable "@\h\w*" display 826b730e11SBram Moolenaarsyn match rubyGlobalVariable "$\%(\h\w*\|-.\)" 83*c1762ccbSBram Moolenaarsyn match rubySymbol "[]})\"':]\@<!:\%(\^\|\~\|<<\|<=>\|<=\|<\|===\|==\|=\~\|>>\|>=\|>\||\|-@\|-\|/\|\[]=\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)" 84*c1762ccbSBram Moolenaarsyn match rubySymbol "[]})\"':]\@<!:\$\%(-.\|[`~<=>_,;:!?/.'"@$*\&+0]\)" 85*c1762ccbSBram Moolenaarsyn match rubySymbol "[]})\"':]\@<!:\%(\$\|@@\=\)\=\h\w*" 86*c1762ccbSBram Moolenaarsyn match rubySymbol "[]})\"':]\@<!:\h\w*[?!=]\=" 87*c1762ccbSBram Moolenaarsyn region rubySymbol start="[]})\"':]\@<!:\"" end="\"" skip="\\\\\|\\\"" 88*c1762ccbSBram Moolenaarsyn region rubySymbol start="[]})\"':]\@<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold 89071d4279SBram Moolenaar 90*c1762ccbSBram Moolenaarsyn match rubyBlockParameter "\h\w*" contained 91*c1762ccbSBram Moolenaarsyn region rubyBlockParameterList start="\%(\%(\<do\>\|{\)\s*\)\@<=|" end="|" oneline display contains=rubyBlockParameter 92*c1762ccbSBram Moolenaar 93*c1762ccbSBram Moolenaarsyn match rubyInvalidVariable "$[^ A-Za-z-]" 946b730e11SBram Moolenaarsyn match rubyPredefinedVariable #$[!$&"'*+,./0:;<=>?@\`~1-9]# 956b730e11SBram Moolenaarsyn match rubyPredefinedVariable "$_\>" display 966b730e11SBram Moolenaarsyn match rubyPredefinedVariable "$-[0FIKadilpvw]\>" display 976b730e11SBram Moolenaarsyn match rubyPredefinedVariable "$\%(deferr\|defout\|stderr\|stdin\|stdout\)\>" display 981e015460SBram Moolenaarsyn match rubyPredefinedVariable "$\%(DEBUG\|FILENAME\|KCODE\|LOADED_FEATURES\|LOAD_PATH\|PROGRAM_NAME\|SAFE\|VERBOSE\)\>" display 996b730e11SBram Moolenaarsyn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(MatchingData\|ARGF\|ARGV\|ENV\)\>\%(\s*(\)\@!" 1006b730e11SBram Moolenaarsyn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(DATA\|FALSE\|NIL\|RUBY_PLATFORM\|RUBY_RELEASE_DATE\)\>\%(\s*(\)\@!" 1016b730e11SBram Moolenaarsyn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(RUBY_VERSION\|STDERR\|STDIN\|STDOUT\|TOPLEVEL_BINDING\|TRUE\)\>\%(\s*(\)\@!" 102071d4279SBram Moolenaar"Obsolete Global Constants 1036b730e11SBram Moolenaar"syn match rubyPredefinedConstant "\%(::\)\=\zs\%(PLATFORM\|RELEASE_DATE\|VERSION\)\>" 1046b730e11SBram Moolenaar"syn match rubyPredefinedConstant "\%(::\)\=\zs\%(NotImplementError\)\>" 105071d4279SBram Moolenaar 106071d4279SBram Moolenaar" Normal Regular Expression 107*c1762ccbSBram Moolenaarsyn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,[>]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyStringSpecial fold 108*c1762ccbSBram Moolenaarsyn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\<\%(split\|scan\|gsub\|sub\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyStringSpecial fold 1096b730e11SBram Moolenaar 1106b730e11SBram Moolenaar" Normal String and Shell Command Output 1119964e468SBram Moolenaarsyn region rubyString matchgroup=rubyStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold 1129964e468SBram Moolenaarsyn region rubyString matchgroup=rubyStringDelimiter start="'" end="'" skip="\\\\\|\\'" fold 1139964e468SBram Moolenaarsyn region rubyString matchgroup=rubyStringDelimiter start="`" end="`" skip="\\\\\|\\`" contains=@rubyStringSpecial fold 1146b730e11SBram Moolenaar 1156b730e11SBram Moolenaar" Generalized Regular Expression 116*c1762ccbSBram Moolenaarsyn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold 117*c1762ccbSBram Moolenaarsyn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimEscape fold 118*c1762ccbSBram Moolenaarsyn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimEscape fold 119*c1762ccbSBram Moolenaarsyn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape fold 120*c1762ccbSBram Moolenaarsyn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape fold 1216b730e11SBram Moolenaar 1226b730e11SBram Moolenaar" Generalized Single Quoted String, Symbol and Array of Strings 123*c1762ccbSBram Moolenaarsyn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold 124*c1762ccbSBram Moolenaarsyn region rubyString matchgroup=rubyStringDelimiter start="%[qw]{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimEscape 125*c1762ccbSBram Moolenaarsyn region rubyString matchgroup=rubyStringDelimiter start="%[qw]<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimEscape 126*c1762ccbSBram Moolenaarsyn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimEscape 127*c1762ccbSBram Moolenaarsyn region rubyString matchgroup=rubyStringDelimiter start="%[qw](" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimEscape 128*c1762ccbSBram Moolenaarsyn region rubySymbol start="%[s]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold 129*c1762ccbSBram Moolenaarsyn region rubySymbol start="%[s]{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimEscape 130*c1762ccbSBram Moolenaarsyn region rubySymbol start="%[s]<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimEscape 131*c1762ccbSBram Moolenaarsyn region rubySymbol start="%[s]\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimEscape 132*c1762ccbSBram Moolenaarsyn region rubySymbol start="%[s](" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimEscape 1336b730e11SBram Moolenaar 1346b730e11SBram Moolenaar" Generalized Double Quoted String and Array of Strings and Shell Command Output 1356b730e11SBram Moolenaar" Note: %= is not matched here as the beginning of a double quoted string 1366b730e11SBram Moolenaarsyn region rubyString matchgroup=rubyStringDelimiter start="%\z([~`!@#$%^&*_\-+|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold 1376b730e11SBram Moolenaarsyn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold 1386b730e11SBram Moolenaarsyn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\={" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimEscape fold 1396b730e11SBram Moolenaarsyn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimEscape fold 1406b730e11SBram Moolenaarsyn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape fold 1416b730e11SBram Moolenaarsyn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape fold 142071d4279SBram Moolenaar 143071d4279SBram Moolenaar" Here Document 144*c1762ccbSBram Moolenaarsyn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs\%(\h\w*\)+ end=+$+ oneline contains=TOP 145*c1762ccbSBram Moolenaarsyn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs"\%([^"]*\)"+ end=+$+ oneline contains=TOP 146*c1762ccbSBram Moolenaarsyn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs'\%([^']*\)'+ end=+$+ oneline contains=TOP 147*c1762ccbSBram Moolenaarsyn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=TOP 148071d4279SBram Moolenaar 149*c1762ccbSBram Moolenaarsyn region rubyString start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<\z(\h\w*\)\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend 150*c1762ccbSBram Moolenaarsyn region rubyString start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<"\z([^"]*\)"\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend 151*c1762ccbSBram Moolenaarsyn region rubyString start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<'\z([^']*\)'\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart fold keepend 152*c1762ccbSBram Moolenaarsyn region rubyString start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<`\z([^`]*\)`\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend 1536b730e11SBram Moolenaar 154*c1762ccbSBram Moolenaarsyn region rubyString start=+\%(\%(class\s*\|\%([]}).]\|::\)\)\_s*\|\w\)\@<!<<-\z(\h\w*\)\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend 155*c1762ccbSBram Moolenaarsyn region rubyString start=+\%(\%(class\s*\|\%([]}).]\|::\)\)\_s*\|\w\)\@<!<<-"\z([^"]*\)"\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend 156*c1762ccbSBram Moolenaarsyn region rubyString start=+\%(\%(class\s*\|\%([]}).]\|::\)\)\_s*\|\w\)\@<!<<-'\z([^']*\)'\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart fold keepend 157*c1762ccbSBram Moolenaarsyn region rubyString start=+\%(\%(class\s*\|\%([]}).]\|::\)\)\_s*\|\w\)\@<!<<-`\z([^`]*\)`\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend 1586b730e11SBram Moolenaar 1596b730e11SBram Moolenaarif exists('main_syntax') && main_syntax == 'eruby' 160d5cdbeb8SBram Moolenaar let b:ruby_no_expensive = 1 1616b730e11SBram Moolenaarend 162071d4279SBram Moolenaar 1639964e468SBram Moolenaarsyn match rubyAliasDeclaration "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable nextgroup=rubyAliasDeclaration2 skipwhite 1649964e468SBram Moolenaarsyn match rubyAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable 1659964e468SBram Moolenaarsyn match rubyMethodDeclaration "[^[:space:];#(]\+" contained contains=rubyConstant,rubyBoolean,rubyPseudoVariable,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable 1669964e468SBram Moolenaarsyn match rubyClassDeclaration "[^[:space:];#<]\+" contained contains=rubyConstant 1679964e468SBram Moolenaarsyn match rubyModuleDeclaration "[^[:space:];#]\+" contained contains=rubyConstant 1689964e468SBram Moolenaarsyn match rubyFunction "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:].:?!=]\@!" contained containedin=rubyMethodDeclaration 1699964e468SBram Moolenaarsyn match rubyFunction "\%(\s\|^\)\@<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2 1709964e468SBram Moolenaarsyn match rubyFunction "\%([[:space:].]\|^\)\@<=\%(\[\]=\=\|\*\*\|[+-]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|==\|=\~\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration 171*c1762ccbSBram Moolenaar 172*c1762ccbSBram Moolenaar" Expensive Mode - match 'end' with the appropriate opening keyword for syntax 173*c1762ccbSBram Moolenaar" based folding and special highlighting of module/class/method definitions 174d5cdbeb8SBram Moolenaarif !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive") 1759964e468SBram Moolenaar syn match rubyDefine "\<alias\>" nextgroup=rubyAliasDeclaration skipwhite skipnl 1769964e468SBram Moolenaar syn match rubyDefine "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl 1779964e468SBram Moolenaar syn match rubyClass "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl 1789964e468SBram Moolenaar syn match rubyModule "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl 1799964e468SBram Moolenaar syn region rubyBlock start="\<def\>" matchgroup=rubyDefine end="\%(\<def\_s\+\)\@<!\<end\>" contains=TOP fold 1809964e468SBram Moolenaar syn region rubyBlock start="\<class\>" matchgroup=rubyClass end="\<end\>" contains=TOP fold 1819964e468SBram Moolenaar syn region rubyBlock start="\<module\>" matchgroup=rubyModule end="\<end\>" contains=TOP fold 182071d4279SBram Moolenaar 1836b730e11SBram Moolenaar " modifiers 184*c1762ccbSBram Moolenaar syn match rubyConditionalModifier "\<\%(if\|unless\)\>" display 185*c1762ccbSBram Moolenaar syn match rubyRepeatModifier "\<\%(while\|until\)\>" display 186071d4279SBram Moolenaar 1879964e468SBram Moolenaar syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=TOP fold 188*c1762ccbSBram Moolenaar " curly bracket block or hash literal 1899964e468SBram Moolenaar syn region rubyCurlyBlock start="{" end="}" contains=TOP fold 190*c1762ccbSBram Moolenaar syn region rubyArrayLiteral matchgroup=rubyArrayDelimiter start="\%(\w\|[\]})]\)\@<!\[" end="]" contains=TOP fold 191071d4279SBram Moolenaar 192*c1762ccbSBram Moolenaar " statements without 'do' 193*c1762ccbSBram Moolenaar syn region rubyBlockExpression matchgroup=rubyControl start="\<begin\>" end="\<end\>" contains=TOP fold 194*c1762ccbSBram Moolenaar syn region rubyCaseExpression matchgroup=rubyConditional start="\<case\>" end="\<end\>" contains=TOP fold 195*c1762ccbSBram Moolenaar syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!?]\)\s*\)\@<=\%(if\|unless\)\>" end="\<end\>" contains=TOP fold 196071d4279SBram Moolenaar 197*c1762ccbSBram Moolenaar syn keyword rubyConditional then else when contained containedin=rubyCaseExpression 198*c1762ccbSBram Moolenaar syn keyword rubyConditional then else elsif contained containedin=rubyConditionalExpression 199*c1762ccbSBram Moolenaar 200*c1762ccbSBram Moolenaar " statements with optional 'do' 201*c1762ccbSBram Moolenaar syn region rubyOptionalDoLine matchgroup=rubyRepeat start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyOptionalDo end="\%(\<do\>\)" end="\ze\%(;\|$\)" oneline contains=TOP 202*c1762ccbSBram Moolenaar syn region rubyRepeatExpression start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat end="\<end\>" contains=TOP nextgroup=rubyOptionalDoLine fold 203071d4279SBram Moolenaar 204071d4279SBram Moolenaar if !exists("ruby_minlines") 205071d4279SBram Moolenaar let ruby_minlines = 50 206071d4279SBram Moolenaar endif 207071d4279SBram Moolenaar exec "syn sync minlines=" . ruby_minlines 208071d4279SBram Moolenaar 2096b730e11SBram Moolenaarelse 2109964e468SBram Moolenaar syn match rubyControl "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl 2119964e468SBram Moolenaar syn match rubyControl "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl 2129964e468SBram Moolenaar syn match rubyControl "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl 2139964e468SBram Moolenaar syn keyword rubyControl case begin do for if unless while until else elsif then when end 2149964e468SBram Moolenaar syn keyword rubyKeyword alias 2156b730e11SBram Moolenaarendif 216071d4279SBram Moolenaar 217071d4279SBram Moolenaar" Keywords 2186b730e11SBram Moolenaar" Note: the following keywords have already been defined: 2196b730e11SBram Moolenaar" begin case class def do end for if module unless until while 2209964e468SBram Moolenaarsyn keyword rubyControl and break ensure in next not or redo rescue retry return 2216b730e11SBram Moolenaarsyn match rubyOperator "\<defined?" display 2229964e468SBram Moolenaarsyn keyword rubyKeyword super undef yield 2236b730e11SBram Moolenaarsyn keyword rubyBoolean true false 2246b730e11SBram Moolenaarsyn keyword rubyPseudoVariable nil self __FILE__ __LINE__ 225071d4279SBram Moolenaarsyn keyword rubyBeginEnd BEGIN END 226071d4279SBram Moolenaar 2276b730e11SBram Moolenaar" Special Methods 2286b730e11SBram Moolenaarif !exists("ruby_no_special_methods") 2296b730e11SBram Moolenaar syn keyword rubyAccess public protected private 2306b730e11SBram Moolenaar syn keyword rubyAttribute attr attr_accessor attr_reader attr_writer 2311e015460SBram Moolenaar syn match rubyControl "\<\%(exit!\|\%(abort\|at_exit\|exit\|fork\|loop\|trap\)\>\)" 2326b730e11SBram Moolenaar syn keyword rubyEval eval class_eval instance_eval module_eval 2336b730e11SBram Moolenaar syn keyword rubyException raise fail catch throw 2346b730e11SBram Moolenaar syn keyword rubyInclude autoload extend include load require 2356b730e11SBram Moolenaar syn keyword rubyKeyword callcc caller lambda proc 236071d4279SBram Moolenaarendif 237071d4279SBram Moolenaar 2386b730e11SBram Moolenaar" Comments and Documentation 2396b730e11SBram Moolenaarsyn match rubySharpBang "\%^#!.*" display 240*c1762ccbSBram Moolenaarsyn keyword rubyTodo FIXME NOTE TODO OPTIMIZE XXX contained 2416b730e11SBram Moolenaarsyn match rubyComment "#.*" contains=rubySharpBang,rubySpaceError,rubyTodo,@Spell 2429964e468SBram Moolenaarif !exists("ruby_no_comment_fold") 2439964e468SBram Moolenaar syn region rubyMultilineComment start="\%(\%(^\s*#.*\n\)\@<!\%(^\s*#.*\n\)\)\%(\(^\s*#.*\n\)\{1,}\)\@=" end="\%(^\s*#.*\n\)\@<=\%(^\s*#.*\n\)\%(^\s*#\)\@!" contains=rubyComment transparent fold keepend 244*c1762ccbSBram Moolenaar syn region rubyDocumentation start="^=begin\ze\%(\s.*\)\=$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell fold 2459964e468SBram Moolenaarelse 2469964e468SBram Moolenaar syn region rubyDocumentation start="^=begin\s*$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell 2479964e468SBram Moolenaarendif 2486b730e11SBram Moolenaar 2496b730e11SBram Moolenaar" Note: this is a hack to prevent 'keywords' being highlighted as such when called as methods with an explicit receiver 2506b730e11SBram Moolenaarsyn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(alias\|and\|begin\|break\|case\|class\|def\|defined\|do\|else\)\>" transparent contains=NONE 2516b730e11SBram Moolenaarsyn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(elsif\|end\|ensure\|false\|for\|if\|in\|module\|next\|nil\)\>" transparent contains=NONE 2526b730e11SBram Moolenaarsyn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(not\|or\|redo\|rescue\|retry\|return\|self\|super\|then\|true\)\>" transparent contains=NONE 2536b730e11SBram Moolenaarsyn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(undef\|unless\|until\|when\|while\|yield\|BEGIN\|END\|__FILE__\|__LINE__\)\>" transparent contains=NONE 2546b730e11SBram Moolenaar 2556b730e11SBram Moolenaarsyn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(abort\|at_exit\|attr\|attr_accessor\|attr_reader\)\>" transparent contains=NONE 2566b730e11SBram Moolenaarsyn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(attr_writer\|autoload\|callcc\|catch\|caller\)\>" transparent contains=NONE 2576b730e11SBram Moolenaarsyn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(eval\|class_eval\|instance_eval\|module_eval\|exit\)\>" transparent contains=NONE 2586b730e11SBram Moolenaarsyn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(extend\|fail\|fork\|include\|lambda\)\>" transparent contains=NONE 2596b730e11SBram Moolenaarsyn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(load\|loop\|private\|proc\|protected\)\>" transparent contains=NONE 2606b730e11SBram Moolenaarsyn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(public\|require\|raise\|throw\|trap\)\>" transparent contains=NONE 261071d4279SBram Moolenaar 262071d4279SBram Moolenaar" __END__ Directive 2636b730e11SBram Moolenaarsyn region rubyData matchgroup=rubyDataDirective start="^__END__$" end="\%$" fold 264071d4279SBram Moolenaar 265*c1762ccbSBram Moolenaarhi def link rubyClass rubyDefine 266*c1762ccbSBram Moolenaarhi def link rubyModule rubyDefine 267*c1762ccbSBram Moolenaarhi def link rubyDefine Define 268*c1762ccbSBram Moolenaarhi def link rubyFunction Function 269*c1762ccbSBram Moolenaarhi def link rubyConditional Conditional 270*c1762ccbSBram Moolenaarhi def link rubyConditionalModifier rubyConditional 271*c1762ccbSBram Moolenaarhi def link rubyRepeat Repeat 272*c1762ccbSBram Moolenaarhi def link rubyRepeatModifier rubyRepeat 273*c1762ccbSBram Moolenaarhi def link rubyOptionalDo rubyRepeat 274*c1762ccbSBram Moolenaarhi def link rubyControl Statement 275*c1762ccbSBram Moolenaarhi def link rubyInclude Include 276*c1762ccbSBram Moolenaarhi def link rubyInteger Number 277*c1762ccbSBram Moolenaarhi def link rubyASCIICode Character 278*c1762ccbSBram Moolenaarhi def link rubyFloat Float 279*c1762ccbSBram Moolenaarhi def link rubyBoolean Boolean 280*c1762ccbSBram Moolenaarhi def link rubyException Exception 2816b730e11SBram Moolenaarif !exists("ruby_no_identifiers") 282*c1762ccbSBram Moolenaar hi def link rubyIdentifier Identifier 2836b730e11SBram Moolenaarelse 284*c1762ccbSBram Moolenaar hi def link rubyIdentifier NONE 2856b730e11SBram Moolenaarendif 286*c1762ccbSBram Moolenaarhi def link rubyClassVariable rubyIdentifier 287*c1762ccbSBram Moolenaarhi def link rubyConstant Type 288*c1762ccbSBram Moolenaarhi def link rubyGlobalVariable rubyIdentifier 289*c1762ccbSBram Moolenaarhi def link rubyBlockParameter rubyIdentifier 290*c1762ccbSBram Moolenaarhi def link rubyInstanceVariable rubyIdentifier 291*c1762ccbSBram Moolenaarhi def link rubyPredefinedIdentifier rubyIdentifier 292*c1762ccbSBram Moolenaarhi def link rubyPredefinedConstant rubyPredefinedIdentifier 293*c1762ccbSBram Moolenaarhi def link rubyPredefinedVariable rubyPredefinedIdentifier 294*c1762ccbSBram Moolenaarhi def link rubySymbol Constant 295*c1762ccbSBram Moolenaarhi def link rubyKeyword Keyword 296*c1762ccbSBram Moolenaarhi def link rubyOperator Operator 297*c1762ccbSBram Moolenaarhi def link rubyPseudoOperator rubyOperator 298*c1762ccbSBram Moolenaarhi def link rubyBeginEnd Statement 299*c1762ccbSBram Moolenaarhi def link rubyAccess Statement 300*c1762ccbSBram Moolenaarhi def link rubyAttribute Statement 301*c1762ccbSBram Moolenaarhi def link rubyEval Statement 302*c1762ccbSBram Moolenaarhi def link rubyPseudoVariable Constant 303071d4279SBram Moolenaar 304*c1762ccbSBram Moolenaarhi def link rubyComment Comment 305*c1762ccbSBram Moolenaarhi def link rubyData Comment 306*c1762ccbSBram Moolenaarhi def link rubyDataDirective Delimiter 307*c1762ccbSBram Moolenaarhi def link rubyDocumentation Comment 308*c1762ccbSBram Moolenaarhi def link rubyEscape Special 309*c1762ccbSBram Moolenaarhi def link rubyInterpolationDelimiter Delimiter 310*c1762ccbSBram Moolenaarhi def link rubyNoInterpolation rubyString 311*c1762ccbSBram Moolenaarhi def link rubySharpBang PreProc 312*c1762ccbSBram Moolenaarhi def link rubyRegexpDelimiter rubyStringDelimiter 313*c1762ccbSBram Moolenaarhi def link rubyStringDelimiter Delimiter 314*c1762ccbSBram Moolenaarhi def link rubyRegexp rubyString 315*c1762ccbSBram Moolenaarhi def link rubyString String 316*c1762ccbSBram Moolenaarhi def link rubyTodo Todo 3176b730e11SBram Moolenaar 318*c1762ccbSBram Moolenaarhi def link rubyInvalidVariable Error 319*c1762ccbSBram Moolenaarhi def link rubyError Error 320*c1762ccbSBram Moolenaarhi def link rubySpaceError rubyError 321071d4279SBram Moolenaar 322071d4279SBram Moolenaarlet b:current_syntax = "ruby" 323071d4279SBram Moolenaar 3249964e468SBram Moolenaar" vim: nowrap sw=2 sts=2 ts=8 noet ff=unix: 325