3 " Maintainer: Doug Kearns <dougkearns@gmail.com>
4 " Info: $Id: ruby.vim,v 1.11 2007/05/12 13:10:02 vimboss Exp $
5 " URL: http://vim-ruby.rubyforge.org
6 " Anon CVS: See above site
7 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
8 " ----------------------------------------------------------------------------
10 " Previous Maintainer: Mirko Nasato
11 " Thanks to perl.vim authors, and to Reimer Behrends. :-) (MN)
12 " ----------------------------------------------------------------------------
14 if exists("b:current_syntax")
18 if has("folding") && exists("ruby_fold")
19 setlocal foldmethod=syntax
22 if exists("ruby_space_errors")
23 if !exists("ruby_no_trail_space_error")
24 syn match rubySpaceError display excludenl "\s\+$"
26 if !exists("ruby_no_tab_space_error")
27 syn match rubySpaceError display " \+\t"me=e-1
32 if exists("ruby_operators")
33 syn match rubyOperator "\%([~!^&|*/%+-]\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|=\@<!>\|\*\*\|\.\.\.\|\.\.\|::\)"
34 syn match rubyPseudoOperator "\%(-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!=\)"
35 syn region rubyBracketOperator matchgroup=rubyOperator start="\%([_[:lower:]]\w*[?!=]\=\|[})]\)\@<=\[\s*" end="\s*]" contains=TOP
38 " Expression Substitution and Backslash Notation
39 syn match rubyEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display
40 syn match rubyEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display
42 syn region rubyInterpolation matchgroup=rubyInterpolationDelimiter start="#{" end="}" contained contains=TOP
43 syn match rubyInterpolation "#\%(\$\|@@\=\)\w\+" display contained contains=rubyInterpolationDelimiter,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable,rubyPredefinedVariable
44 syn match rubyInterpolationDelimiter "#\ze\%(\$\|@@\=\)\w\+" display contained
45 syn match rubyInterpolation "#\$\%(-\w\|\W\)" display contained contains=rubyInterpolationDelimiter,rubyPredefinedVariable,rubyInvalidVariable
46 syn match rubyInterpolationDelimiter "#\ze\$\%(-\w\|\W\)" display contained
47 syn region rubyNoInterpolation start="\\#{" end="}" contained
48 syn match rubyNoInterpolation "\\#{" display contained
49 syn match rubyNoInterpolation "\\#\%(\$\|@@\=\)\w\+" display contained
50 syn match rubyNoInterpolation "\\#\$\W" display contained
52 syn match rubyDelimEscape "\\[(<{\[)>}\]]" transparent display contained contains=NONE
54 syn region rubyNestedParentheses start="(" end=")" skip="\\\\\|\\)" transparent contained contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape
55 syn region rubyNestedCurlyBraces start="{" end="}" skip="\\\\\|\\}" transparent contained contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimEscape
56 syn region rubyNestedAngleBrackets start="<" end=">" skip="\\\\\|\\>" transparent contained contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimEscape
57 if exists("ruby_operators")
58 syn region rubyNestedSquareBrackets start="\[" end="\]" skip="\\\\\|\\\]" transparent contained contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape
60 syn region rubyNestedSquareBrackets start="\[" end="\]" skip="\\\\\|\\\]" transparent containedin=rubyArrayLiteral contained contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape
63 syn cluster rubyStringSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyEscape
64 syn cluster rubyExtendedStringSpecial contains=@rubyStringSpecial,rubyNestedParentheses,rubyNestedCurlyBraces,rubyNestedAngleBrackets,rubyNestedSquareBrackets
66 " Numbers and ASCII Codes
67 syn match rubyASCIICode "\%(\w\|[]})\"'/]\)\@<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)\)"
68 syn match rubyInteger "\<0[xX]\x\+\%(_\x\+\)*\>" display
69 syn match rubyInteger "\<\%(0[dD]\)\=\%(0\|[1-9]\d*\%(_\d\+\)*\)\>" display
70 syn match rubyInteger "\<0[oO]\=\o\+\%(_\o\+\)*\>" display
71 syn match rubyInteger "\<0[bB][01]\+\%(_[01]\+\)*\>" display
72 syn match rubyFloat "\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\.\d\+\%(_\d\+\)*\>" display
73 syn match rubyFloat "\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\%(\.\d\+\%(_\d\+\)*\)\=\%([eE][-+]\=\d\+\%(_\d\+\)*\)\>" display
76 syn match rubyLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent
77 syn match rubyBlockArgument "&[_[:lower:]][_[:alnum:]]" contains=NONE display transparent
79 syn match rubyConstant "\%(\%([.@$]\@<!\.\)\@<!\<\|::\)\_s*\zs\u\w*\%(\>\|::\)\@=\%(\s*(\)\@!"
80 syn match rubyClassVariable "@@\h\w*" display
81 syn match rubyInstanceVariable "@\h\w*" display
82 syn match rubyGlobalVariable "$\%(\h\w*\|-.\)"
83 syn match rubySymbol "[]})\"':]\@<!:\%(\^\|\~\|<<\|<=>\|<=\|<\|===\|==\|=\~\|>>\|>=\|>\||\|-@\|-\|/\|\[]=\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)"
84 syn match rubySymbol "[]})\"':]\@<!:\$\%(-.\|[`~<=>_,;:!?/.'"@$*\&+0]\)"
85 syn match rubySymbol "[]})\"':]\@<!:\%(\$\|@@\=\)\=\h\w*"
86 syn match rubySymbol "[]})\"':]\@<!:\h\w*[?!=]\="
87 syn region rubySymbol start="[]})\"':]\@<!:\"" end="\"" skip="\\\\\|\\\""
88 syn region rubySymbol start="[]})\"':]\@<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold
90 syn match rubyBlockParameter "\h\w*" contained
91 syn region rubyBlockParameterList start="\%(\%(\<do\>\|{\)\s*\)\@<=|" end="|" oneline display contains=rubyBlockParameter
93 syn match rubyInvalidVariable "$[^ A-Za-z-]"
94 syn match rubyPredefinedVariable #$[!$&"'*+,./0:;<=>?@\`~1-9]#
95 syn match rubyPredefinedVariable "$_\>" display
96 syn match rubyPredefinedVariable "$-[0FIKadilpvw]\>" display
97 syn match rubyPredefinedVariable "$\%(deferr\|defout\|stderr\|stdin\|stdout\)\>" display
98 syn match rubyPredefinedVariable "$\%(DEBUG\|FILENAME\|KCODE\|LOADED_FEATURES\|LOAD_PATH\|PROGRAM_NAME\|SAFE\|VERBOSE\)\>" display
99 syn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(MatchingData\|ARGF\|ARGV\|ENV\)\>\%(\s*(\)\@!"
100 syn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(DATA\|FALSE\|NIL\|RUBY_PLATFORM\|RUBY_RELEASE_DATE\)\>\%(\s*(\)\@!"
101 syn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(RUBY_VERSION\|STDERR\|STDIN\|STDOUT\|TOPLEVEL_BINDING\|TRUE\)\>\%(\s*(\)\@!"
102 "Obsolete Global Constants
103 "syn match rubyPredefinedConstant "\%(::\)\=\zs\%(PLATFORM\|RELEASE_DATE\|VERSION\)\>"
104 "syn match rubyPredefinedConstant "\%(::\)\=\zs\%(NotImplementError\)\>"
106 " Normal Regular Expression
107 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,[>]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyStringSpecial fold
108 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\<\%(split\|scan\|gsub\|sub\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyStringSpecial fold
110 " Normal String and Shell Command Output
111 syn region rubyString matchgroup=rubyStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold
112 syn region rubyString matchgroup=rubyStringDelimiter start="'" end="'" skip="\\\\\|\\'" fold
113 syn region rubyString matchgroup=rubyStringDelimiter start="`" end="`" skip="\\\\\|\\`" contains=@rubyStringSpecial fold
115 " Generalized Regular Expression
116 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold
117 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimEscape fold
118 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimEscape fold
119 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape fold
120 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape fold
122 " Generalized Single Quoted String, Symbol and Array of Strings
123 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold
124 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimEscape
125 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimEscape
126 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimEscape
127 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw](" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimEscape
128 syn region rubySymbol start="%[s]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold
129 syn region rubySymbol start="%[s]{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimEscape
130 syn region rubySymbol start="%[s]<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimEscape
131 syn region rubySymbol start="%[s]\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimEscape
132 syn region rubySymbol start="%[s](" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimEscape
134 " Generalized Double Quoted String and Array of Strings and Shell Command Output
135 " Note: %= is not matched here as the beginning of a double quoted string
136 syn region rubyString matchgroup=rubyStringDelimiter start="%\z([~`!@#$%^&*_\-+|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold
137 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold
138 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\={" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimEscape fold
139 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimEscape fold
140 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape fold
141 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape fold
144 syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs\%(\h\w*\)+ end=+$+ oneline contains=TOP
145 syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs"\%([^"]*\)"+ end=+$+ oneline contains=TOP
146 syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs'\%([^']*\)'+ end=+$+ oneline contains=TOP
147 syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=TOP
149 syn region rubyString start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<\z(\h\w*\)\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
150 syn region rubyString start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<"\z([^"]*\)"\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
151 syn region rubyString start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<'\z([^']*\)'\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart fold keepend
152 syn region rubyString start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<`\z([^`]*\)`\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
154 syn 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 syn region rubyString start=+\%(\%(class\s*\|\%([]}).]\|::\)\)\_s*\|\w\)\@<!<<-"\z([^"]*\)"\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
156 syn region rubyString start=+\%(\%(class\s*\|\%([]}).]\|::\)\)\_s*\|\w\)\@<!<<-'\z([^']*\)'\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart fold keepend
157 syn region rubyString start=+\%(\%(class\s*\|\%([]}).]\|::\)\)\_s*\|\w\)\@<!<<-`\z([^`]*\)`\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
159 if exists('main_syntax') && main_syntax == 'eruby'
160 let b:ruby_no_expensive = 1
163 syn match rubyAliasDeclaration "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable nextgroup=rubyAliasDeclaration2 skipwhite
164 syn match rubyAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable
165 syn match rubyMethodDeclaration "[^[:space:];#(]\+" contained contains=rubyConstant,rubyBoolean,rubyPseudoVariable,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable
166 syn match rubyClassDeclaration "[^[:space:];#<]\+" contained contains=rubyConstant
167 syn match rubyModuleDeclaration "[^[:space:];#]\+" contained contains=rubyConstant
168 syn match rubyFunction "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:].:?!=]\@!" contained containedin=rubyMethodDeclaration
169 syn match rubyFunction "\%(\s\|^\)\@<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2
170 syn match rubyFunction "\%([[:space:].]\|^\)\@<=\%(\[\]=\=\|\*\*\|[+-]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|==\|=\~\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration
172 " Expensive Mode - match 'end' with the appropriate opening keyword for syntax
173 " based folding and special highlighting of module/class/method definitions
174 if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive")
175 syn match rubyDefine "\<alias\>" nextgroup=rubyAliasDeclaration skipwhite skipnl
176 syn match rubyDefine "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl
177 syn match rubyClass "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl
178 syn match rubyModule "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl
179 syn region rubyBlock start="\<def\>" matchgroup=rubyDefine end="\%(\<def\_s\+\)\@<!\<end\>" contains=TOP fold
180 syn region rubyBlock start="\<class\>" matchgroup=rubyClass end="\<end\>" contains=TOP fold
181 syn region rubyBlock start="\<module\>" matchgroup=rubyModule end="\<end\>" contains=TOP fold
184 syn match rubyConditionalModifier "\<\%(if\|unless\)\>" display
185 syn match rubyRepeatModifier "\<\%(while\|until\)\>" display
187 syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=TOP fold
188 " curly bracket block or hash literal
189 syn region rubyCurlyBlock start="{" end="}" contains=TOP fold
190 syn region rubyArrayLiteral matchgroup=rubyArrayDelimiter start="\%(\w\|[\]})]\)\@<!\[" end="]" contains=TOP fold
192 " statements without 'do'
193 syn region rubyBlockExpression matchgroup=rubyControl start="\<begin\>" end="\<end\>" contains=TOP fold
194 syn region rubyCaseExpression matchgroup=rubyConditional start="\<case\>" end="\<end\>" contains=TOP fold
195 syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!?]\)\s*\)\@<=\%(if\|unless\)\>" end="\<end\>" contains=TOP fold
197 syn keyword rubyConditional then else when contained containedin=rubyCaseExpression
198 syn keyword rubyConditional then else elsif contained containedin=rubyConditionalExpression
200 " statements with optional 'do'
201 syn region rubyOptionalDoLine matchgroup=rubyRepeat start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyOptionalDo end="\%(\<do\>\)" end="\ze\%(;\|$\)" oneline contains=TOP
202 syn region rubyRepeatExpression start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat end="\<end\>" contains=TOP nextgroup=rubyOptionalDoLine fold
204 if !exists("ruby_minlines")
205 let ruby_minlines = 50
207 exec "syn sync minlines=" . ruby_minlines
210 syn match rubyControl "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl
211 syn match rubyControl "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl
212 syn match rubyControl "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl
213 syn keyword rubyControl case begin do for if unless while until else elsif then when end
214 syn keyword rubyKeyword alias
218 " Note: the following keywords have already been defined:
219 " begin case class def do end for if module unless until while
220 syn keyword rubyControl and break ensure in next not or redo rescue retry return
221 syn match rubyOperator "\<defined?" display
222 syn keyword rubyKeyword super undef yield
223 syn keyword rubyBoolean true false
224 syn keyword rubyPseudoVariable nil self __FILE__ __LINE__
225 syn keyword rubyBeginEnd BEGIN END
228 if !exists("ruby_no_special_methods")
229 syn keyword rubyAccess public protected private
230 syn keyword rubyAttribute attr attr_accessor attr_reader attr_writer
231 syn match rubyControl "\<\%(exit!\|\%(abort\|at_exit\|exit\|fork\|loop\|trap\)\>\)"
232 syn keyword rubyEval eval class_eval instance_eval module_eval
233 syn keyword rubyException raise fail catch throw
234 syn keyword rubyInclude autoload extend include load require
235 syn keyword rubyKeyword callcc caller lambda proc
238 " Comments and Documentation
239 syn match rubySharpBang "\%^#!.*" display
240 syn keyword rubyTodo FIXME NOTE TODO OPTIMIZE XXX contained
241 syn match rubyComment "#.*" contains=rubySharpBang,rubySpaceError,rubyTodo,@Spell
242 if !exists("ruby_no_comment_fold")
243 syn region rubyMultilineComment start="\%(\%(^\s*#.*\n\)\@<!\%(^\s*#.*\n\)\)\%(\(^\s*#.*\n\)\{1,}\)\@=" end="\%(^\s*#.*\n\)\@<=\%(^\s*#.*\n\)\%(^\s*#\)\@!" contains=rubyComment transparent fold keepend
244 syn region rubyDocumentation start="^=begin\ze\%(\s.*\)\=$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell fold
246 syn region rubyDocumentation start="^=begin\s*$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell
249 " Note: this is a hack to prevent 'keywords' being highlighted as such when called as methods with an explicit receiver
250 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(alias\|and\|begin\|break\|case\|class\|def\|defined\|do\|else\)\>" transparent contains=NONE
251 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(elsif\|end\|ensure\|false\|for\|if\|in\|module\|next\|nil\)\>" transparent contains=NONE
252 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(not\|or\|redo\|rescue\|retry\|return\|self\|super\|then\|true\)\>" transparent contains=NONE
253 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(undef\|unless\|until\|when\|while\|yield\|BEGIN\|END\|__FILE__\|__LINE__\)\>" transparent contains=NONE
255 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(abort\|at_exit\|attr\|attr_accessor\|attr_reader\)\>" transparent contains=NONE
256 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(attr_writer\|autoload\|callcc\|catch\|caller\)\>" transparent contains=NONE
257 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(eval\|class_eval\|instance_eval\|module_eval\|exit\)\>" transparent contains=NONE
258 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(extend\|fail\|fork\|include\|lambda\)\>" transparent contains=NONE
259 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(load\|loop\|private\|proc\|protected\)\>" transparent contains=NONE
260 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(public\|require\|raise\|throw\|trap\)\>" transparent contains=NONE
263 syn region rubyData matchgroup=rubyDataDirective start="^__END__$" end="\%$" fold
265 hi def link rubyClass rubyDefine
266 hi def link rubyModule rubyDefine
267 hi def link rubyDefine Define
268 hi def link rubyFunction Function
269 hi def link rubyConditional Conditional
270 hi def link rubyConditionalModifier rubyConditional
271 hi def link rubyRepeat Repeat
272 hi def link rubyRepeatModifier rubyRepeat
273 hi def link rubyOptionalDo rubyRepeat
274 hi def link rubyControl Statement
275 hi def link rubyInclude Include
276 hi def link rubyInteger Number
277 hi def link rubyASCIICode Character
278 hi def link rubyFloat Float
279 hi def link rubyBoolean Boolean
280 hi def link rubyException Exception
281 if !exists("ruby_no_identifiers")
282 hi def link rubyIdentifier Identifier
284 hi def link rubyIdentifier NONE
286 hi def link rubyClassVariable rubyIdentifier
287 hi def link rubyConstant Type
288 hi def link rubyGlobalVariable rubyIdentifier
289 hi def link rubyBlockParameter rubyIdentifier
290 hi def link rubyInstanceVariable rubyIdentifier
291 hi def link rubyPredefinedIdentifier rubyIdentifier
292 hi def link rubyPredefinedConstant rubyPredefinedIdentifier
293 hi def link rubyPredefinedVariable rubyPredefinedIdentifier
294 hi def link rubySymbol Constant
295 hi def link rubyKeyword Keyword
296 hi def link rubyOperator Operator
297 hi def link rubyPseudoOperator rubyOperator
298 hi def link rubyBeginEnd Statement
299 hi def link rubyAccess Statement
300 hi def link rubyAttribute Statement
301 hi def link rubyEval Statement
302 hi def link rubyPseudoVariable Constant
304 hi def link rubyComment Comment
305 hi def link rubyData Comment
306 hi def link rubyDataDirective Delimiter
307 hi def link rubyDocumentation Comment
308 hi def link rubyEscape Special
309 hi def link rubyInterpolationDelimiter Delimiter
310 hi def link rubyNoInterpolation rubyString
311 hi def link rubySharpBang PreProc
312 hi def link rubyRegexpDelimiter rubyStringDelimiter
313 hi def link rubyStringDelimiter Delimiter
314 hi def link rubyRegexp rubyString
315 hi def link rubyString String
316 hi def link rubyTodo Todo
318 hi def link rubyInvalidVariable Error
319 hi def link rubyError Error
320 hi def link rubySpaceError rubyError
322 let b:current_syntax = "ruby"
324 " vim: nowrap sw=2 sts=2 ts=8 noet ff=unix: