|
43 | 43 | syn match rubyEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display |
44 | 44 | syn match rubyEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display |
45 | 45 | syn region rubyInterpolated matchgroup=rubyInterpolation start="#{" end="}" contains=TOP contained |
| 46 | +"syn match rubyInterpolation "#\%(\$\|@@\=\)\w\+" contained contains=rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable display |
46 | 47 | syn match rubyInterpolation "#\ze\%(\$\|@@\=\)\w\+" contained display nextgroup=rubyClassVariable,rubyInstanceVariable,rubyGlobalVariable |
47 | 48 | syn match rubyNoInterpolation "\\#{[^}]*}" contained |
48 | 49 | syn match rubyNoInterpolation "\\#\%(\$\|@@\=\)\w\+" contained display |
@@ -70,7 +71,7 @@ syn match rubyFloat "\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\%(\.\d\+\%(_\d\+\)*\)\=\%([eE |
70 | 71 | syn match rubyLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent |
71 | 72 | syn match rubyBlockArgument "&[_[:lower:]][_[:alnum:]]" contains=NONE display transparent |
72 | 73 |
|
73 | | -syn match rubyConstant "\%(\%(\.\@<!\.\)\@<!\<\|::\)\_s*\zs\u\w*\>\%(\s*(\)\@!" |
| 74 | +syn match rubyConstant "\%(\%([.@$]\@<!\.\)\@<!\<\|::\)\_s*\zs\u\w*\>\%(\s*(\)\@!" |
74 | 75 | syn match rubyClassVariable "@@\h\w*" display |
75 | 76 | syn match rubyInstanceVariable "@\h\w*" display |
76 | 77 | syn match rubyGlobalVariable "$\%(\h\w*\|-.\)" |
@@ -148,50 +149,54 @@ if exists('main_syntax') && main_syntax == 'eruby' |
148 | 149 | let b:ruby_no_expensive = 1 |
149 | 150 | end |
150 | 151 |
|
| 152 | +syn match rubyMethodDeclaration "[_[:alnum:]@$][^[:space:];#(]*" contained contains=rubyFunction,rubyConstant,rubyBoolean,rubyPseudoVariable,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable |
| 153 | +syn match rubyClassDeclaration "[_[:alnum:]@$][^[:space:];#(]*" contained contains=rubyConstant |
| 154 | +syn match rubyModuleDeclaration "[_[:alnum:]@$][^[:space:];#(]*" contained contains=rubyConstant |
| 155 | +syn match rubyFunction "\<[_[:lower:]][_[:alnum:]]*[?!=]\=.\@!" contained |
151 | 156 | " Expensive Mode - colorize *end* according to opening statement |
152 | 157 | if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive") |
153 | | - syn region rubyFunction matchgroup=rubyDefine start="\<def\>\s*" end="\%(\s*\%(\s\|(\|;\|$\|#\)\)\@=" oneline contains=rubyPseudoVariable |
154 | | - syn region rubyClass matchgroup=rubyType start="\<class\>\s*" end="\%(\s*\%(\s\|<\|;\|$\|#\)\)\@=" oneline |
155 | | - syn match rubyType "\<class\ze\s*<<" |
156 | | - syn region rubyModule matchgroup=rubyType start="\<module\>\s*" end="\%(\s*\%(\s\|;\|$\|#\)\)\@=" oneline |
157 | | - |
158 | | - syn region rubyBlock start="\<def\>" matchgroup=rubyDefine end="\<end\>" contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo nextgroup=rubyFunction fold |
159 | | - syn region rubyBlock start="\<class\>" matchgroup=rubyType end="\<end\>" contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo nextgroup=rubyClass fold |
160 | | - syn region rubyBlock start="\<module\>" matchgroup=rubyType end="\<end\>" contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo nextgroup=rubyModule fold |
| 158 | + syn match rubyDefine "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl |
| 159 | + syn match rubyClass "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl |
| 160 | + syn match rubyModule "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl |
| 161 | + syn region rubyBlock start="\<def\>" matchgroup=rubyDefine end="\<end\>" contains=TOP fold |
| 162 | + syn region rubyBlock start="\<class\>" matchgroup=rubyClass end="\<end\>" contains=TOP fold |
| 163 | + syn region rubyBlock start="\<module\>" matchgroup=rubyModule end="\<end\>" contains=TOP fold |
161 | 164 |
|
162 | 165 | " modifiers |
163 | | - syn match rubyControl "\<\%(if\|unless\|while\|until\)\>" display |
| 166 | + syn match rubyConditional "\<\%(if\|unless\)\>" display |
| 167 | + syn match rubyLoop "\<\%(while\|until\)\>" display |
164 | 168 |
|
165 | 169 | " *do* requiring *end* |
166 | | - syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo fold |
| 170 | + syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=TOP fold |
167 | 171 |
|
168 | 172 | " *{* requiring *}* |
169 | | - syn region rubyCurlyBlock start="{" end="}" contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo fold |
| 173 | + syn region rubyCurlyBlock start="{" end="}" contains=TOP fold |
170 | 174 |
|
171 | 175 | " statements without *do* |
172 | | - syn region rubyNoDoBlock matchgroup=rubyControl start="\<\%(case\|begin\)\>" start="\%(^\|\.\.\.\=\|[,;=([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\zs\%(if\|unless\)\>" end="\<end\>" contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo fold |
| 176 | + syn region rubyNoDoBlock matchgroup=rubyControl start="\<begin\>" end="\<end\>" contains=TOP fold |
| 177 | + syn region rubyNoDoBlock matchgroup=rubyConditional start="\<case\>" start="\%(^\|\.\.\.\=\|[,;=([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\zs\%(if\|unless\)\>" end="\<end\>" contains=TOP fold |
| 178 | + syn keyword rubyConditional else elsif then when |
173 | 179 |
|
174 | 180 | " statement with optional *do* |
175 | | - syn region rubyOptDoLine matchgroup=rubyControl start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[?:,;=([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" end="\%(\<do\>\|:\)" end="\ze\%(;\|$\)" oneline contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo |
176 | | - syn region rubyOptDoBlock start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyControl end="\<end\>" contains=ALLBUT,@rubyExtendedStringSpecial,rubyTodo nextgroup=rubyOptDoLine fold |
| 181 | + syn region rubyOptDoLine matchgroup=rubyLoop start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[?:,;=([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" end="\%(\<do\>\|:\)" end="\ze\%(;\|$\)" oneline contains=TOP |
| 182 | + syn region rubyOptDoBlock start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyLoop end="\<end\>" contains=TOP nextgroup=rubyOptDoLine fold |
177 | 183 |
|
178 | 184 | if !exists("ruby_minlines") |
179 | 185 | let ruby_minlines = 50 |
180 | 186 | endif |
181 | 187 | exec "syn sync minlines=" . ruby_minlines |
182 | 188 |
|
183 | 189 | else |
184 | | - syn region rubyFunction matchgroup=rubyControl start="\<def\>\s*" end="\ze\%(\s\|(\|;\|$\)" oneline contains=rubyPseudoVariable |
185 | | - syn region rubyClass matchgroup=rubyControl start="\<class\>\s*" end="\ze\%(\s\|<\|;\|$\)" oneline |
186 | | - syn match rubyControl "\<class\ze\s*<<" |
187 | | - syn region rubyModule matchgroup=rubyControl start="\<module\>\s*" end="\ze\%(\s\|;\|$\)" oneline |
188 | | - syn keyword rubyControl case begin do for if unless while until end |
| 190 | + syn match rubyControl "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl |
| 191 | + syn match rubyControl "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl |
| 192 | + syn match rubyControl "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl |
| 193 | + syn keyword rubyControl case begin do for if unless while until else elsif then when end |
189 | 194 | endif |
190 | 195 |
|
191 | 196 | " Keywords |
192 | 197 | " Note: the following keywords have already been defined: |
193 | 198 | " begin case class def do end for if module unless until while |
194 | | -syn keyword rubyControl and break else elsif ensure in next not or redo rescue retry return then when |
| 199 | +syn keyword rubyControl and break ensure in next not or redo rescue retry return |
195 | 200 | syn match rubyOperator "\<defined?" display |
196 | 201 | syn keyword rubyKeyword alias super undef yield |
197 | 202 | syn keyword rubyBoolean true false |
@@ -247,32 +252,33 @@ if version >= 508 || !exists("did_ruby_syntax_inits") |
247 | 252 | command -nargs=+ HiLink hi def link <args> |
248 | 253 | endif |
249 | 254 |
|
250 | | - HiLink rubyType rubyDefine |
| 255 | + HiLink rubyClass rubyDefine |
| 256 | + HiLink rubyModule rubyDefine |
251 | 257 | HiLink rubyDefine Define |
252 | 258 | HiLink rubyFunction Function |
| 259 | + HiLink rubyConditional Conditional |
| 260 | + HiLink rubyLoop Loop |
253 | 261 | HiLink rubyControl Statement |
254 | 262 | HiLink rubyInclude Include |
255 | 263 | HiLink rubyInteger Number |
256 | | - HiLink rubyASCIICode rubyInteger |
| 264 | + HiLink rubyASCIICode Character |
257 | 265 | HiLink rubyFloat Float |
258 | | - HiLink rubyBoolean rubyPseudoVariable |
| 266 | + HiLink rubyBoolean Boolean |
259 | 267 | HiLink rubyException Exception |
260 | | - HiLink rubyClass Type |
261 | | - HiLink rubyModule Type |
262 | 268 | if !exists("ruby_no_identifiers") |
263 | 269 | HiLink rubyIdentifier Identifier |
264 | 270 | else |
265 | 271 | HiLink rubyIdentifier NONE |
266 | 272 | endif |
267 | 273 | HiLink rubyClassVariable rubyIdentifier |
268 | | - HiLink rubyConstant rubyIdentifier |
| 274 | + HiLink rubyConstant Type |
269 | 275 | HiLink rubyGlobalVariable rubyIdentifier |
270 | 276 | HiLink rubyBlockParameter rubyIdentifier |
271 | 277 | HiLink rubyInstanceVariable rubyIdentifier |
272 | 278 | HiLink rubyPredefinedIdentifier rubyIdentifier |
273 | 279 | HiLink rubyPredefinedConstant rubyPredefinedIdentifier |
274 | 280 | HiLink rubyPredefinedVariable rubyPredefinedIdentifier |
275 | | - HiLink rubySymbol rubyIdentifier |
| 281 | + HiLink rubySymbol Constant |
276 | 282 | HiLink rubyKeyword Keyword |
277 | 283 | HiLink rubyOperator Operator |
278 | 284 | HiLink rubyPseudoOperator rubyOperator |
@@ -304,4 +310,4 @@ endif |
304 | 310 |
|
305 | 311 | let b:current_syntax = "ruby" |
306 | 312 |
|
307 | | -" vim: nowrap sw=2 sts=2 ts=8 ff=unix: |
| 313 | +" vim: nowrap sw=2 sts=2 ts=8 noet ff=unix: |
0 commit comments