diff options
author | Bram Moolenaar <Bram@vim.org> | 2007-05-05 17:54:07 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2007-05-05 17:54:07 +0000 |
commit | 9964e468c0209f6b8286e0b08109817c845a3079 (patch) | |
tree | 3c53288cff0d4c2e32169d8eb4cd53cc343ad0bc /runtime/syntax/ruby.vim | |
parent | d5ab34bd5ecc748d5502f149c476968e5ec2b7c9 (diff) | |
download | vim-9964e468c0209f6b8286e0b08109817c845a3079.zip |
updated for version 7.1a
Diffstat (limited to 'runtime/syntax/ruby.vim')
-rw-r--r-- | runtime/syntax/ruby.vim | 149 |
1 files changed, 93 insertions, 56 deletions
diff --git a/runtime/syntax/ruby.vim b/runtime/syntax/ruby.vim index 94434aed3..c45aae2a1 100644 --- a/runtime/syntax/ruby.vim +++ b/runtime/syntax/ruby.vim @@ -32,13 +32,23 @@ if exists("ruby_space_errors") endif endif +" Operators +if exists("ruby_operators") + syn match rubyOperator "\%(\^\|\~\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|>\||\|-\|/\|\*\*\|\*\|&\|%\|+\)" + syn match rubyPseudoOperator "\%(-=\|/=\|\*\*=\|\*=\|&&\|&=\|&&=\|||\||=\|||=\|%=\|+=\|!\~\|!=\)" + syn region rubyBracketOperator matchgroup=rubyOperator start="\%([_[:lower:]]\w*[?!=]\=\|}\)\@<=\[\s*" end="\s*]" +endif + " Expression Substitution and Backslash Notation -syn match rubyEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display -syn match rubyEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display -syn match rubyInterpolation "#{[^}]*}" contained -syn match rubyInterpolation "#\%(\$\|@@\=\)\w\+" contained display -syn match rubyNoInterpolation "\\#{[^}]*}" contained -syn match rubyNoInterpolation "\\#\%(\$\|@@\=\)\w\+" contained display +syn match rubyEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display +syn match rubyEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display + +syn region rubyInterpolation matchgroup=rubyInterpolationDelimiter start="#{" end="}" contained contains=TOP +syn match rubyInterpolation "#\%(\$\|@@\=\)\w\+" display contained contains=rubyInterpolationDelimiter,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable,rubyPredefinedVariable +syn match rubyInterpolationDelimiter "#\ze\%(\$\|@@\=\)\w\+" display contained +syn region rubyNoInterpolation start="\\#{" end="}" contained +syn match rubyNoInterpolation "\\#{" display contained +syn match rubyNoInterpolation "\\#\%(\$\|@@\=\)\w\+" display contained syn match rubyDelimEscape "\\[(<{\[)>}\]]" transparent display contained contains=NONE @@ -63,7 +73,7 @@ syn match rubyFloat "\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\%(\.\d\+\%(_\d\+\)*\)\=\%([eE syn match rubyLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent syn match rubyBlockArgument "&[_[:lower:]][_[:alnum:]]" contains=NONE display transparent -syn match rubyConstant "\%(\%(\.\@<!\.\)\@<!\<\|::\)\_s*\zs\u\w*\>\%(\s*(\)\@!" +syn match rubyConstant "\%(\%([.@$]\@<!\.\)\@<!\<\|::\)\_s*\zs\u\w*\%(\>\|::\)\@=\%(\s*(\)\@!" syn match rubyClassVariable "@@\h\w*" display syn match rubyInstanceVariable "@\h\w*" display syn match rubyGlobalVariable "$\%(\h\w*\|-.\)" @@ -71,7 +81,12 @@ syn match rubySymbol ":\@<!:\%(\^\|\~\|<<\|<=>\|<=\|<\|===\|==\|=\~\|>>\|>=\| syn match rubySymbol ":\@<!:\$\%(-.\|[`~<=>_,;:!?/.'"@$*\&+0]\)" syn match rubySymbol ":\@<!:\%(\$\|@@\=\)\=\h\w*[?!=]\=" syn region rubySymbol start=":\@<!:\"" end="\"" skip="\\\\\|\\\"" -syn match rubyBlockParameter "\%(\%(\<do\>\|{\)\s*\)\@<=|\s*\zs[( ,a-zA-Z0-9_*)]\+\ze\s*|" display +syn region rubySymbol start=":\@<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold +if exists("ruby_operators") + syn match rubyBlockParameter "\%(\%(\%(\<do\>\|{\)\s*\)|\s*\)\@<=[( ,a-zA-Z0-9_*)]\+\%(\s*|\)\@=" display +else + syn match rubyBlockParameter "\%(\%(\<do\>\|{\)\s*\)\@<=|\s*\zs[( ,a-zA-Z0-9_*)]\+\ze\s*|" display +endif syn match rubyPredefinedVariable #$[!$&"'*+,./0:;<=>?@\`~1-9]# syn match rubyPredefinedVariable "$_\>" display @@ -86,20 +101,20 @@ syn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(RUBY_VERSI "syn match rubyPredefinedConstant "\%(::\)\=\zs\%(NotImplementError\)\>" " Normal Regular Expression -syn region rubyString matchgroup=rubyStringDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\)\|[;\~=!|&(,[>]\)\s*\)\@<=/" end="/[iomx]*" skip="\\\\\|\\/" contains=@rubyStringSpecial -syn region rubyString matchgroup=rubyStringDelimiter start="\%(\<\%(split\|scan\|gsub\|sub\)\s*\)\@<=/" end="/[iomx]*" skip="\\\\\|\\/" contains=@rubyStringSpecial +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\)\|[;\~=!|&(,[>]\)\s*\)\@<=/" end="/[iomx]*" skip="\\\\\|\\/" contains=@rubyStringSpecial fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\<\%(split\|scan\|gsub\|sub\)\s*\)\@<=/" end="/[iomx]*" skip="\\\\\|\\/" contains=@rubyStringSpecial fold " Normal String and Shell Command Output -syn region rubyString matchgroup=rubyStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial -syn region rubyString matchgroup=rubyStringDelimiter start="'" end="'" skip="\\\\\|\\'" -syn region rubyString matchgroup=rubyStringDelimiter start="`" end="`" skip="\\\\\|\\`" contains=@rubyStringSpecial +syn region rubyString matchgroup=rubyStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold +syn region rubyString matchgroup=rubyStringDelimiter start="'" end="'" skip="\\\\\|\\'" fold +syn region rubyString matchgroup=rubyStringDelimiter start="`" end="`" skip="\\\\\|\\`" contains=@rubyStringSpecial fold " Generalized Regular Expression -syn region rubyString matchgroup=rubyStringDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomx]*" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold -syn region rubyString matchgroup=rubyStringDelimiter start="%r{" end="}[iomx]*" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimEscape fold -syn region rubyString matchgroup=rubyStringDelimiter start="%r<" end=">[iomx]*" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimEscape fold -syn region rubyString matchgroup=rubyStringDelimiter start="%r\[" end="\][iomx]*" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape fold -syn region rubyString matchgroup=rubyStringDelimiter start="%r(" end=")[iomx]*" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomx]*" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{" end="}[iomx]*" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimEscape fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<" end=">[iomx]*" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimEscape fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][iomx]*" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomx]*" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape fold " Generalized Single Quoted String, Symbol and Array of Strings syn region rubyString matchgroup=rubyStringDelimiter start="%[qsw]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold @@ -123,46 +138,58 @@ syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s* syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<-\=\zs'\%([^']*\)'+ end=+$+ oneline contains=TOP syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<-\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=TOP -syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<\z(\h\w*\)\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial nextgroup=rubyFunction fold keepend -syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<"\z([^"]*\)"\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial nextgroup=rubyFunction fold keepend -syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<'\z([^']*\)'\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart nextgroup=rubyFunction fold keepend -syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<`\z([^`]*\)`\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial nextgroup=rubyFunction fold keepend +syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<\z(\h\w*\)\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend +syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<"\z([^"]*\)"\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend +syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<'\z([^']*\)'\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart fold keepend +syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<`\z([^`]*\)`\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend -syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<-\z(\h\w*\)\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial nextgroup=rubyFunction fold keepend -syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<-"\z([^"]*\)"\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial nextgroup=rubyFunction fold keepend -syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<-'\z([^']*\)'\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart nextgroup=rubyFunction fold keepend -syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<-`\z([^`]*\)`\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial nextgroup=rubyFunction fold keepend +syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<-\z(\h\w*\)\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend +syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<-"\z([^"]*\)"\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend +syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<-'\z([^']*\)'\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart fold keepend +syn region rubyString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@<!<<-`\z([^`]*\)`\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend if exists('main_syntax') && main_syntax == 'eruby' let b:ruby_no_expensive = 1 end +syn match rubyAliasDeclaration "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable nextgroup=rubyAliasDeclaration2 skipwhite +syn match rubyAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable +syn match rubyMethodDeclaration "[^[:space:];#(]\+" contained contains=rubyConstant,rubyBoolean,rubyPseudoVariable,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable +syn match rubyClassDeclaration "[^[:space:];#<]\+" contained contains=rubyConstant +syn match rubyModuleDeclaration "[^[:space:];#]\+" contained contains=rubyConstant +syn match rubyFunction "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:].:?!=]\@!" contained containedin=rubyMethodDeclaration +syn match rubyFunction "\%(\s\|^\)\@<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2 +syn match rubyFunction "\%([[:space:].]\|^\)\@<=\%(\[\]=\=\|\*\*\|[+-]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|==\|=\~\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration " Expensive Mode - colorize *end* according to opening statement if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive") - syn region rubyFunction matchgroup=rubyDefine start="\<def\s\+" end="\%(\s*\%(\s\|(\|;\|$\|#\)\)\@=" oneline - syn region rubyClass matchgroup=rubyDefine start="\<class\s\+" end="\%(\s*\%(\s\|<\|;\|$\|#\)\)\@=" oneline - syn match rubyDefine "\<class\ze<<" - syn region rubyModule matchgroup=rubyDefine start="\<module\s\+" end="\%(\s*\%(\s\|;\|$\|#\)\)\@=" oneline - - syn region rubyBlock start="\<def\>" matchgroup=rubyDefine end="\<end\>" contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo nextgroup=rubyFunction fold - syn region rubyBlock start="\<class\>" matchgroup=rubyDefine end="\<end\>" contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo nextgroup=rubyClass fold - syn region rubyBlock start="\<module\>" matchgroup=rubyDefine end="\<end\>" contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo nextgroup=rubyModule fold + syn match rubyDefine "\<alias\>" nextgroup=rubyAliasDeclaration skipwhite skipnl + syn match rubyDefine "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl + syn match rubyClass "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl + syn match rubyModule "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl + syn region rubyBlock start="\<def\>" matchgroup=rubyDefine end="\%(\<def\_s\+\)\@<!\<end\>" contains=TOP fold + syn region rubyBlock start="\<class\>" matchgroup=rubyClass end="\<end\>" contains=TOP fold + syn region rubyBlock start="\<module\>" matchgroup=rubyModule end="\<end\>" contains=TOP fold " modifiers - syn match rubyControl "\<\%(if\|unless\|while\|until\)\>" display + syn match rubyConditional "\<\%(if\|unless\)\>" display + syn match rubyRepeat "\<\%(while\|until\)\>" display " *do* requiring *end* - syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo fold + syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=TOP fold " *{* requiring *}* - syn region rubyCurlyBlock start="{" end="}" contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo fold + syn region rubyCurlyBlock start="{" end="}" contains=TOP fold " statements without *do* - syn region rubyNoDoBlock matchgroup=rubyControl start="\<\%(case\|begin\)\>" start="\%(^\|\.\.\.\=\|[,;=([<>~\*/%!&^|+-]\)\s*\zs\%(if\|unless\)\>" end="\<end\>" contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo fold + syn region rubyNoDoBlock matchgroup=rubyControl start="\<begin\>" end="\<end\>" contains=TOP fold + syn region rubyCaseBlock matchgroup=rubyConditional start="\<case\>" end="\<end\>" contains=TOP fold + syn region rubyConditionalBlock matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\%(if\|unless\)\>" end="\<end\>" contains=TOP fold + syn keyword rubyConditional then else when contained containedin=rubyCaseBlock + syn keyword rubyConditional then else elsif contained containedin=rubyConditionalBlock " statement with optional *do* - syn region rubyOptDoLine matchgroup=rubyControl start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[?:,;=([<>~\*/%!&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" end="\%(\<do\>\|:\)" end="\ze\%(;\|$\)" oneline contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo - syn region rubyOptDoBlock start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyControl end="\<end\>" contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo nextgroup=rubyOptDoLine fold + syn region rubyOptDoLine matchgroup=rubyRepeat start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" end="\%(\<do\>\|:\)" end="\ze\%(;\|$\)" oneline contains=TOP + syn region rubyOptDoBlock start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat end="\<end\>" contains=TOP nextgroup=rubyOptDoLine fold if !exists("ruby_minlines") let ruby_minlines = 50 @@ -170,19 +197,19 @@ if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive") exec "syn sync minlines=" . ruby_minlines else - syn region rubyFunction matchgroup=rubyControl start="\<def\s\+" end="\ze\%(\s\|(\|;\|$\)" oneline - syn region rubyClass matchgroup=rubyControl start="\<class\s\+" end="\ze\%(\s\|<\|;\|$\)" oneline - syn match rubyControl "\<class\ze<<" - syn region rubyModule matchgroup=rubyControl start="\<module\s\+" end="\ze\%(\s\|;\|$\)" oneline - syn keyword rubyControl case begin do for if unless while until end + syn match rubyControl "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl + syn match rubyControl "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl + syn match rubyControl "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl + syn keyword rubyControl case begin do for if unless while until else elsif then when end + syn keyword rubyKeyword alias endif " Keywords " Note: the following keywords have already been defined: " begin case class def do end for if module unless until while -syn keyword rubyControl and break else elsif ensure in next not or redo rescue retry return then when +syn keyword rubyControl and break ensure in next not or redo rescue retry return syn match rubyOperator "\<defined?" display -syn keyword rubyKeyword alias super undef yield +syn keyword rubyKeyword super undef yield syn keyword rubyBoolean true false syn keyword rubyPseudoVariable nil self __FILE__ __LINE__ syn keyword rubyBeginEnd BEGIN END @@ -202,7 +229,12 @@ endif syn match rubySharpBang "\%^#!.*" display syn keyword rubyTodo FIXME NOTE TODO XXX contained syn match rubyComment "#.*" contains=rubySharpBang,rubySpaceError,rubyTodo,@Spell -syn region rubyDocumentation start="^=begin" end="^=end.*$" contains=rubySpaceError,rubyTodo,@Spell fold +if !exists("ruby_no_comment_fold") + syn region rubyMultilineComment start="\%(\%(^\s*#.*\n\)\@<!\%(^\s*#.*\n\)\)\%(\(^\s*#.*\n\)\{1,}\)\@=" end="\%(^\s*#.*\n\)\@<=\%(^\s*#.*\n\)\%(^\s*#\)\@!" contains=rubyComment transparent fold keepend + syn region rubyDocumentation start="^=begin\s*$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell fold +else + syn region rubyDocumentation start="^=begin\s*$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell +endif " Note: this is a hack to prevent 'keywords' being highlighted as such when called as methods with an explicit receiver syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(alias\|and\|begin\|break\|case\|class\|def\|defined\|do\|else\)\>" transparent contains=NONE @@ -231,33 +263,36 @@ if version >= 508 || !exists("did_ruby_syntax_inits") command -nargs=+ HiLink hi def link <args> endif + HiLink rubyClass rubyDefine + HiLink rubyModule rubyDefine HiLink rubyDefine Define HiLink rubyFunction Function + HiLink rubyConditional Conditional + HiLink rubyRepeat Repeat HiLink rubyControl Statement HiLink rubyInclude Include HiLink rubyInteger Number - HiLink rubyASCIICode rubyInteger + HiLink rubyASCIICode Character HiLink rubyFloat Float - HiLink rubyBoolean rubyPseudoVariable + HiLink rubyBoolean Boolean HiLink rubyException Exception - HiLink rubyClass Type - HiLink rubyModule Type if !exists("ruby_no_identifiers") HiLink rubyIdentifier Identifier else HiLink rubyIdentifier NONE endif HiLink rubyClassVariable rubyIdentifier - HiLink rubyConstant rubyIdentifier + HiLink rubyConstant Type HiLink rubyGlobalVariable rubyIdentifier HiLink rubyBlockParameter rubyIdentifier HiLink rubyInstanceVariable rubyIdentifier HiLink rubyPredefinedIdentifier rubyIdentifier HiLink rubyPredefinedConstant rubyPredefinedIdentifier HiLink rubyPredefinedVariable rubyPredefinedIdentifier - HiLink rubySymbol rubyIdentifier + HiLink rubySymbol Constant HiLink rubyKeyword Keyword HiLink rubyOperator Operator + HiLink rubyPseudoOperator rubyOperator HiLink rubyBeginEnd Statement HiLink rubyAccess Statement HiLink rubyAttribute Statement @@ -269,10 +304,12 @@ if version >= 508 || !exists("did_ruby_syntax_inits") HiLink rubyDataDirective Delimiter HiLink rubyDocumentation Comment HiLink rubyEscape Special - HiLink rubyInterpolation Special + HiLink rubyInterpolationDelimiter Delimiter HiLink rubyNoInterpolation rubyString HiLink rubySharpBang PreProc + HiLink rubyRegexpDelimiter rubyStringDelimiter HiLink rubyStringDelimiter Delimiter + HiLink rubyRegexp rubyString HiLink rubyString String HiLink rubyTodo Todo @@ -284,4 +321,4 @@ endif let b:current_syntax = "ruby" -" vim: nowrap sw=2 sts=2 ts=8 ff=unix: +" vim: nowrap sw=2 sts=2 ts=8 noet ff=unix: |