7
|
1 " Vim syntax file
|
831
|
2 " Language: Ruby
|
|
3 " Maintainer: Doug Kearns <dougkearns@gmail.com>
|
2225
|
4 " Last Change: 2009 Dec 2
|
831
|
5 " URL: http://vim-ruby.rubyforge.org
|
|
6 " Anon CVS: See above site
|
|
7 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
529
|
8 " ----------------------------------------------------------------------------
|
|
9 "
|
7
|
10 " Previous Maintainer: Mirko Nasato
|
|
11 " Thanks to perl.vim authors, and to Reimer Behrends. :-) (MN)
|
529
|
12 " ----------------------------------------------------------------------------
|
7
|
13
|
1190
|
14 if exists("b:current_syntax")
|
7
|
15 finish
|
|
16 endif
|
|
17
|
529
|
18 if has("folding") && exists("ruby_fold")
|
|
19 setlocal foldmethod=syntax
|
|
20 endif
|
7
|
21
|
2225
|
22 syn cluster rubyNotTop contains=@rubyExtendedStringSpecial,@rubyRegexpSpecial,@rubyDeclaration,rubyConditional,rubyExceptional,rubyMethodExceptional,rubyTodo
|
1668
|
23
|
529
|
24 if exists("ruby_space_errors")
|
|
25 if !exists("ruby_no_trail_space_error")
|
|
26 syn match rubySpaceError display excludenl "\s\+$"
|
|
27 endif
|
|
28 if !exists("ruby_no_tab_space_error")
|
|
29 syn match rubySpaceError display " \+\t"me=e-1
|
|
30 endif
|
7
|
31 endif
|
|
32
|
1121
|
33 " Operators
|
|
34 if exists("ruby_operators")
|
1190
|
35 syn match rubyOperator "\%([~!^&|*/%+-]\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|=\@<!>\|\*\*\|\.\.\.\|\.\.\|::\)"
|
|
36 syn match rubyPseudoOperator "\%(-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!=\)"
|
1668
|
37 syn region rubyBracketOperator matchgroup=rubyOperator start="\%(\w[?!]\=\|[]})]\)\@<=\[\s*" end="\s*]" contains=ALLBUT,@rubyNotTop
|
1121
|
38 endif
|
|
39
|
529
|
40 " Expression Substitution and Backslash Notation
|
2225
|
41 syn match rubyStringEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display
|
|
42 syn match rubyStringEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display
|
|
43 syn match rubyQuoteEscape "\\[\\']" contained display
|
1121
|
44
|
1668
|
45 syn region rubyInterpolation matchgroup=rubyInterpolationDelimiter start="#{" end="}" contained contains=ALLBUT,@rubyNotTop
|
2225
|
46 syn match rubyInterpolation "#\%(\$\|@@\=\)\w\+" display contained contains=rubyInterpolationDelimiter,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable,rubyPredefinedVariable
|
1121
|
47 syn match rubyInterpolationDelimiter "#\ze\%(\$\|@@\=\)\w\+" display contained
|
2225
|
48 syn match rubyInterpolation "#\$\%(-\w\|\W\)" display contained contains=rubyInterpolationDelimiter,rubyPredefinedVariable,rubyInvalidVariable
|
1190
|
49 syn match rubyInterpolationDelimiter "#\ze\$\%(-\w\|\W\)" display contained
|
2225
|
50 syn region rubyNoInterpolation start="\\#{" end="}" contained
|
1121
|
51 syn match rubyNoInterpolation "\\#{" display contained
|
|
52 syn match rubyNoInterpolation "\\#\%(\$\|@@\=\)\w\+" display contained
|
2225
|
53 syn match rubyNoInterpolation "\\#\$\W" display contained
|
529
|
54
|
|
55 syn match rubyDelimEscape "\\[(<{\[)>}\]]" transparent display contained contains=NONE
|
|
56
|
2225
|
57 syn region rubyNestedParentheses start="(" skip="\\\\\|\\)" matchgroup=rubyString end=")" transparent contained
|
|
58 syn region rubyNestedCurlyBraces start="{" skip="\\\\\|\\}" matchgroup=rubyString end="}" transparent contained
|
|
59 syn region rubyNestedAngleBrackets start="<" skip="\\\\\|\\>" matchgroup=rubyString end=">" transparent contained
|
|
60 syn region rubyNestedSquareBrackets start="\[" skip="\\\\\|\\\]" matchgroup=rubyString end="\]" transparent contained
|
529
|
61
|
1668
|
62 " These are mostly Oniguruma ready
|
2225
|
63 syn region rubyRegexpComment matchgroup=rubyRegexpSpecial start="(?#" skip="\\)" end=")" contained
|
|
64 syn region rubyRegexpParens matchgroup=rubyRegexpSpecial start="(\(?:\|?<\=[=!]\|?>\|?<[a-z_]\w*>\|?[imx]*-[imx]*:\=\|\%(?#\)\@!\)" skip="\\)" end=")" contained transparent contains=@rubyRegexpSpecial
|
|
65 syn region rubyRegexpBrackets matchgroup=rubyRegexpCharClass start="\[\^\=" skip="\\\]" end="\]" contained transparent contains=rubyStringEscape,rubyRegexpEscape,rubyRegexpCharClass oneline
|
|
66 syn match rubyRegexpCharClass "\\[DdHhSsWw]" contained display
|
|
67 syn match rubyRegexpCharClass "\[:\^\=\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|xdigit\):\]" contained
|
|
68 syn match rubyRegexpEscape "\\[].*?+^$|\\/(){}[]" contained
|
|
69 syn match rubyRegexpQuantifier "[*?+][?+]\=" contained display
|
|
70 syn match rubyRegexpQuantifier "{\d\+\%(,\d*\)\=}?\=" contained display
|
|
71 syn match rubyRegexpAnchor "[$^]\|\\[ABbGZz]" contained display
|
|
72 syn match rubyRegexpDot "\." contained display
|
|
73 syn match rubyRegexpSpecial "|" contained display
|
|
74 syn match rubyRegexpSpecial "\\[1-9]\d\=\d\@!" contained display
|
1668
|
75 syn match rubyRegexpSpecial "\\k<\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\=>" contained display
|
|
76 syn match rubyRegexpSpecial "\\k'\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\='" contained display
|
|
77 syn match rubyRegexpSpecial "\\g<\%([a-z_]\w*\|-\=\d\+\)>" contained display
|
|
78 syn match rubyRegexpSpecial "\\g'\%([a-z_]\w*\|-\=\d\+\)'" contained display
|
|
79
|
2225
|
80 syn cluster rubyStringSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyStringEscape
|
|
81 syn cluster rubyExtendedStringSpecial contains=@rubyStringSpecial,rubyNestedParentheses,rubyNestedCurlyBraces,rubyNestedAngleBrackets,rubyNestedSquareBrackets
|
|
82 syn cluster rubyRegexpSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyStringEscape,rubyRegexpSpecial,rubyRegexpEscape,rubyRegexpBrackets,rubyRegexpCharClass,rubyRegexpDot,rubyRegexpQuantifier,rubyRegexpAnchor,rubyRegexpParens,rubyRegexpComment
|
529
|
83
|
|
84 " Numbers and ASCII Codes
|
1190
|
85 syn match rubyASCIICode "\%(\w\|[]})\"'/]\)\@<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)\)"
|
2225
|
86 syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[xX]\x\+\%(_\x\+\)*\>" display
|
|
87 syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0[dD]\)\=\%(0\|[1-9]\d*\%(_\d\+\)*\)\>" display
|
|
88 syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[oO]\=\o\+\%(_\o\+\)*\>" display
|
|
89 syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[bB][01]\+\%(_[01]\+\)*\>" display
|
|
90 syn match rubyFloat "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\.\d\+\%(_\d\+\)*\>" display
|
|
91 syn match rubyFloat "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\%(\.\d\+\%(_\d\+\)*\)\=\%([eE][-+]\=\d\+\%(_\d\+\)*\)\>" display
|
7
|
92
|
529
|
93 " Identifiers
|
|
94 syn match rubyLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent
|
|
95 syn match rubyBlockArgument "&[_[:lower:]][_[:alnum:]]" contains=NONE display transparent
|
|
96
|
2225
|
97 syn match rubyConstant "\%(\%([.@$]\@<!\.\)\@<!\<\|::\)\_s*\zs\u\w*\%(\>\|::\)\@=\%(\s*(\)\@!"
|
|
98 syn match rubyClassVariable "@@\h\w*" display
|
|
99 syn match rubyInstanceVariable "@\h\w*" display
|
|
100 syn match rubyGlobalVariable "$\%(\h\w*\|-.\)"
|
|
101 syn match rubySymbol "[]})\"':]\@<!:\%(\^\|\~\|<<\|<=>\|<=\|<\|===\|==\|=\~\|>>\|>=\|>\||\|-@\|-\|/\|\[]=\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)"
|
|
102 syn match rubySymbol "[]})\"':]\@<!:\$\%(-.\|[`~<=>_,;:!?/.'"@$*\&+0]\)"
|
|
103 syn match rubySymbol "[]})\"':]\@<!:\%(\$\|@@\=\)\=\h\w*"
|
|
104 syn match rubySymbol "[]})\"':]\@<!:\h\w*\%([?!=]>\@!\)\="
|
|
105 syn match rubySymbol "\%([{(,]\_s*\)\@<=\l\w*[!?]\=::\@!"he=e-1
|
|
106 syn match rubySymbol "[]})\"':]\@<!\h\w*[!?]\=:\s\@="he=e-1
|
|
107 syn region rubySymbol start="[]})\"':]\@<!:'" end="'" skip="\\\\\|\\'" contains=rubyQuoteEscape fold
|
|
108 syn region rubySymbol start="[]})\"':]\@<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold
|
7
|
109
|
2225
|
110 syn match rubyBlockParameter "\h\w*" contained
|
|
111 syn region rubyBlockParameterList start="\%(\%(\<do\>\|{\)\s*\)\@<=|" end="|" oneline display contains=rubyBlockParameter
|
1190
|
112
|
2225
|
113 syn match rubyInvalidVariable "$[^ A-Za-z_-]"
|
529
|
114 syn match rubyPredefinedVariable #$[!$&"'*+,./0:;<=>?@\`~1-9]#
|
532
|
115 syn match rubyPredefinedVariable "$_\>" display
|
|
116 syn match rubyPredefinedVariable "$-[0FIKadilpvw]\>" display
|
|
117 syn match rubyPredefinedVariable "$\%(deferr\|defout\|stderr\|stdin\|stdout\)\>" display
|
|
118 syn match rubyPredefinedVariable "$\%(DEBUG\|FILENAME\|KCODE\|LOADED_FEATURES\|LOAD_PATH\|PROGRAM_NAME\|SAFE\|VERBOSE\)\>" display
|
529
|
119 syn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(MatchingData\|ARGF\|ARGV\|ENV\)\>\%(\s*(\)\@!"
|
|
120 syn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(DATA\|FALSE\|NIL\|RUBY_PLATFORM\|RUBY_RELEASE_DATE\)\>\%(\s*(\)\@!"
|
|
121 syn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(RUBY_VERSION\|STDERR\|STDIN\|STDOUT\|TOPLEVEL_BINDING\|TRUE\)\>\%(\s*(\)\@!"
|
|
122 "Obsolete Global Constants
|
|
123 "syn match rubyPredefinedConstant "\%(::\)\=\zs\%(PLATFORM\|RELEASE_DATE\|VERSION\)\>"
|
|
124 "syn match rubyPredefinedConstant "\%(::\)\=\zs\%(NotImplementError\)\>"
|
|
125
|
|
126 " Normal Regular Expression
|
1668
|
127 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,[>]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial keepend fold
|
|
128 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/[ \t=]\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold
|
|
129
|
|
130 " Generalized Regular Expression
|
2225
|
131 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial fold
|
|
132 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyRegexpSpecial fold
|
|
133 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyRegexpSpecial,rubyNestedAngleBrackets,rubyDelimEscape fold
|
|
134 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyRegexpSpecial fold
|
|
135 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyRegexpSpecial fold
|
7
|
136
|
|
137 " Normal String and Shell Command Output
|
1121
|
138 syn region rubyString matchgroup=rubyStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold
|
2225
|
139 syn region rubyString matchgroup=rubyStringDelimiter start="'" end="'" skip="\\\\\|\\'" contains=rubyQuoteEscape fold
|
1121
|
140 syn region rubyString matchgroup=rubyStringDelimiter start="`" end="`" skip="\\\\\|\\`" contains=@rubyStringSpecial fold
|
529
|
141
|
|
142 " Generalized Single Quoted String, Symbol and Array of Strings
|
2225
|
143 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold
|
|
144 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimEscape
|
|
145 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimEscape
|
|
146 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimEscape
|
|
147 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw](" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimEscape
|
|
148 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%[s]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold
|
|
149 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%[s]{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimEscape
|
|
150 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%[s]<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimEscape
|
|
151 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%[s]\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimEscape
|
|
152 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%[s](" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimEscape
|
529
|
153
|
|
154 " Generalized Double Quoted String and Array of Strings and Shell Command Output
|
|
155 " Note: %= is not matched here as the beginning of a double quoted string
|
|
156 syn region rubyString matchgroup=rubyStringDelimiter start="%\z([~`!@#$%^&*_\-+|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold
|
|
157 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold
|
2225
|
158 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\={" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimEscape fold
|
|
159 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimEscape fold
|
529
|
160 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape fold
|
2225
|
161 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape fold
|
7
|
162
|
|
163 " Here Document
|
2225
|
164 syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs\%(\h\w*\)+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
|
1668
|
165 syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs"\%([^"]*\)"+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
|
|
166 syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs'\%([^']*\)'+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
|
|
167 syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
|
7
|
168
|
2225
|
169 syn region rubyString start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<\z(\h\w*\)\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
|
|
170 syn region rubyString start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<"\z([^"]*\)"\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
|
|
171 syn region rubyString start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<'\z([^']*\)'\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart fold keepend
|
|
172 syn region rubyString start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<`\z([^`]*\)`\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
|
529
|
173
|
1190
|
174 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
|
|
175 syn region rubyString start=+\%(\%(class\s*\|\%([]}).]\|::\)\)\_s*\|\w\)\@<!<<-"\z([^"]*\)"\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
|
|
176 syn region rubyString start=+\%(\%(class\s*\|\%([]}).]\|::\)\)\_s*\|\w\)\@<!<<-'\z([^']*\)'\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart fold keepend
|
|
177 syn region rubyString start=+\%(\%(class\s*\|\%([]}).]\|::\)\)\_s*\|\w\)\@<!<<-`\z([^`]*\)`\ze+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
|
529
|
178
|
|
179 if exists('main_syntax') && main_syntax == 'eruby'
|
548
|
180 let b:ruby_no_expensive = 1
|
529
|
181 end
|
7
|
182
|
2225
|
183 syn match rubyAliasDeclaration "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable nextgroup=rubyAliasDeclaration2 skipwhite
|
|
184 syn match rubyAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable
|
|
185 syn match rubyMethodDeclaration "[^[:space:];#(]\+" contained contains=rubyConstant,rubyBoolean,rubyPseudoVariable,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable
|
|
186 syn match rubyClassDeclaration "[^[:space:];#<]\+" contained contains=rubyConstant,rubyOperator
|
|
187 syn match rubyModuleDeclaration "[^[:space:];#<]\+" contained contains=rubyConstant,rubyOperator
|
|
188 syn match rubyFunction "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:]_.:?!=]\@!" contained containedin=rubyMethodDeclaration
|
1121
|
189 syn match rubyFunction "\%(\s\|^\)\@<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2
|
|
190 syn match rubyFunction "\%([[:space:].]\|^\)\@<=\%(\[\]=\=\|\*\*\|[+-]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|==\|=\~\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration
|
1190
|
191
|
2225
|
192 syn cluster rubyDeclaration contains=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration,rubyModuleDeclaration,rubyClassDeclaration,rubyFunction,rubyBlockParameter
|
|
193
|
|
194 " Keywords
|
|
195 " Note: the following keywords have already been defined:
|
|
196 " begin case class def do end for if module unless until while
|
|
197 syn match rubyControl "\<\%(and\|break\|in\|next\|not\|or\|redo\|rescue\|retry\|return\)\>[?!]\@!"
|
|
198 syn match rubyOperator "\<defined?" display
|
|
199 syn match rubyKeyword "\<\%(super\|yield\)\>[?!]\@!"
|
|
200 syn match rubyBoolean "\<\%(true\|false\)\>[?!]\@!"
|
|
201 syn match rubyPseudoVariable "\<\%(nil\|self\|__FILE__\|__LINE__\)\>[?!]\@!"
|
|
202 syn match rubyBeginEnd "\<\%(BEGIN\|END\)\>[?!]\@!"
|
1668
|
203
|
1190
|
204 " Expensive Mode - match 'end' with the appropriate opening keyword for syntax
|
|
205 " based folding and special highlighting of module/class/method definitions
|
548
|
206 if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive")
|
2225
|
207 syn match rubyDefine "\<alias\>" nextgroup=rubyAliasDeclaration skipwhite skipnl
|
|
208 syn match rubyDefine "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl
|
|
209 syn match rubyDefine "\<undef\>" nextgroup=rubyFunction skipwhite skipnl
|
|
210 syn match rubyClass "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl
|
|
211 syn match rubyModule "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl
|
|
212
|
|
213 syn region rubyMethodBlock start="\<def\>" matchgroup=rubyDefine end="\%(\<def\_s\+\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop fold
|
|
214 syn region rubyBlock start="\<class\>" matchgroup=rubyClass end="\<end\>" contains=ALLBUT,@rubyNotTop fold
|
|
215 syn region rubyBlock start="\<module\>" matchgroup=rubyModule end="\<end\>" contains=ALLBUT,@rubyNotTop fold
|
7
|
216
|
529
|
217 " modifiers
|
2225
|
218 syn match rubyConditionalModifier "\<\%(if\|unless\)\>" display
|
|
219 syn match rubyRepeatModifier "\<\%(while\|until\)\>" display
|
7
|
220
|
2225
|
221 syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold
|
1190
|
222 " curly bracket block or hash literal
|
2225
|
223 syn region rubyCurlyBlock start="{" end="}" contains=ALLBUT,@rubyNotTop fold
|
1668
|
224 syn region rubyArrayLiteral matchgroup=rubyArrayDelimiter start="\%(\w\|[\]})]\)\@<!\[" end="]" contains=ALLBUT,@rubyNotTop fold
|
7
|
225
|
1190
|
226 " statements without 'do'
|
1668
|
227 syn region rubyBlockExpression matchgroup=rubyControl start="\<begin\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold
|
|
228 syn region rubyCaseExpression matchgroup=rubyConditional start="\<case\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold
|
|
229 syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![?!]\)\s*\)\@<=\%(if\|unless\)\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold
|
7
|
230
|
2225
|
231 syn match rubyConditional "\<\%(then\|else\|when\)\>[?!]\@!" contained containedin=rubyCaseExpression
|
1668
|
232 syn match rubyConditional "\<\%(then\|else\|elsif\)\>[?!]\@!" contained containedin=rubyConditionalExpression
|
1190
|
233
|
2225
|
234 syn match rubyExceptional "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=rubyBlockExpression
|
|
235 syn match rubyMethodExceptional "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=rubyMethodBlock
|
|
236
|
1190
|
237 " statements with optional 'do'
|
1668
|
238 syn region rubyOptionalDoLine matchgroup=rubyRepeat start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyOptionalDo end="\%(\<do\>\)" end="\ze\%(;\|$\)" oneline contains=ALLBUT,@rubyNotTop
|
|
239 syn region rubyRepeatExpression start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat end="\<end\>" contains=ALLBUT,@rubyNotTop nextgroup=rubyOptionalDoLine fold
|
7
|
240
|
|
241 if !exists("ruby_minlines")
|
|
242 let ruby_minlines = 50
|
|
243 endif
|
|
244 exec "syn sync minlines=" . ruby_minlines
|
|
245
|
529
|
246 else
|
2225
|
247 syn match rubyControl "\<def\>[?!]\@!" nextgroup=rubyMethodDeclaration skipwhite skipnl
|
|
248 syn match rubyControl "\<class\>[?!]\@!" nextgroup=rubyClassDeclaration skipwhite skipnl
|
|
249 syn match rubyControl "\<module\>[?!]\@!" nextgroup=rubyModuleDeclaration skipwhite skipnl
|
|
250 syn match rubyControl "\<\%(case\|begin\|do\|for\|if\|unless\|while\|until\|else\|elsif\|ensure\|then\|when\|end\)\>[?!]\@!"
|
|
251 syn match rubyKeyword "\<\%(alias\|undef\)\>[?!]\@!"
|
529
|
252 endif
|
7
|
253
|
529
|
254 " Special Methods
|
|
255 if !exists("ruby_no_special_methods")
|
1668
|
256 syn keyword rubyAccess public protected private module_function
|
|
257 " attr is a common variable name
|
|
258 syn match rubyAttribute "\%(\%(^\|;\)\s*\)\@<=attr\>\(\s*[.=]\)\@!"
|
|
259 syn keyword rubyAttribute attr_accessor attr_reader attr_writer
|
|
260 syn match rubyControl "\<\%(exit!\|\%(abort\|at_exit\|exit\|fork\|loop\|trap\)\>[?!]\@!\)"
|
548
|
261 syn keyword rubyEval eval class_eval instance_eval module_eval
|
529
|
262 syn keyword rubyException raise fail catch throw
|
1668
|
263 " false positive with 'include?'
|
|
264 syn match rubyInclude "\<include\>[?!]\@!"
|
|
265 syn keyword rubyInclude autoload extend load require
|
529
|
266 syn keyword rubyKeyword callcc caller lambda proc
|
|
267 endif
|
7
|
268
|
|
269 " Comments and Documentation
|
2225
|
270 syn match rubySharpBang "\%^#!.*" display
|
|
271 syn keyword rubyTodo FIXME NOTE TODO OPTIMIZE XXX contained
|
|
272 syn match rubyComment "#.*" contains=rubySharpBang,rubySpaceError,rubyTodo,@Spell
|
1121
|
273 if !exists("ruby_no_comment_fold")
|
|
274 syn region rubyMultilineComment start="\%(\%(^\s*#.*\n\)\@<!\%(^\s*#.*\n\)\)\%(\(^\s*#.*\n\)\{1,}\)\@=" end="\%(^\s*#.*\n\)\@<=\%(^\s*#.*\n\)\%(^\s*#\)\@!" contains=rubyComment transparent fold keepend
|
1190
|
275 syn region rubyDocumentation start="^=begin\ze\%(\s.*\)\=$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell fold
|
1121
|
276 else
|
|
277 syn region rubyDocumentation start="^=begin\s*$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell
|
|
278 endif
|
7
|
279
|
529
|
280 " Note: this is a hack to prevent 'keywords' being highlighted as such when called as methods with an explicit receiver
|
2225
|
281 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(alias\|and\|begin\|break\|case\|class\|def\|defined\|do\|else\)\>" transparent contains=NONE
|
|
282 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(elsif\|end\|ensure\|false\|for\|if\|in\|module\|next\|nil\)\>" transparent contains=NONE
|
|
283 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(not\|or\|redo\|rescue\|retry\|return\|self\|super\|then\|true\)\>" transparent contains=NONE
|
|
284 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(undef\|unless\|until\|when\|while\|yield\|BEGIN\|END\|__FILE__\|__LINE__\)\>" transparent contains=NONE
|
529
|
285
|
2225
|
286 syn match rubyKeywordAsMethod "\<\%(alias\|begin\|case\|class\|def\|do\|end\)[?!]" transparent contains=NONE
|
|
287 syn match rubyKeywordAsMethod "\<\%(if\|module\|undef\|unless\|until\|while\)[?!]" transparent contains=NONE
|
1668
|
288
|
2225
|
289 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(abort\|at_exit\|attr\|attr_accessor\|attr_reader\)\>" transparent contains=NONE
|
|
290 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(attr_writer\|autoload\|callcc\|catch\|caller\)\>" transparent contains=NONE
|
|
291 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(eval\|class_eval\|instance_eval\|module_eval\|exit\)\>" transparent contains=NONE
|
|
292 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(extend\|fail\|fork\|include\|lambda\)\>" transparent contains=NONE
|
|
293 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(load\|loop\|private\|proc\|protected\)\>" transparent contains=NONE
|
|
294 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(public\|require\|raise\|throw\|trap\)\>" transparent contains=NONE
|
7
|
295
|
|
296 " __END__ Directive
|
529
|
297 syn region rubyData matchgroup=rubyDataDirective start="^__END__$" end="\%$" fold
|
7
|
298
|
1190
|
299 hi def link rubyClass rubyDefine
|
|
300 hi def link rubyModule rubyDefine
|
2225
|
301 hi def link rubyMethodExceptional rubyDefine
|
1190
|
302 hi def link rubyDefine Define
|
|
303 hi def link rubyFunction Function
|
|
304 hi def link rubyConditional Conditional
|
|
305 hi def link rubyConditionalModifier rubyConditional
|
2225
|
306 hi def link rubyExceptional rubyConditional
|
1190
|
307 hi def link rubyRepeat Repeat
|
|
308 hi def link rubyRepeatModifier rubyRepeat
|
|
309 hi def link rubyOptionalDo rubyRepeat
|
|
310 hi def link rubyControl Statement
|
|
311 hi def link rubyInclude Include
|
|
312 hi def link rubyInteger Number
|
|
313 hi def link rubyASCIICode Character
|
|
314 hi def link rubyFloat Float
|
|
315 hi def link rubyBoolean Boolean
|
|
316 hi def link rubyException Exception
|
|
317 if !exists("ruby_no_identifiers")
|
|
318 hi def link rubyIdentifier Identifier
|
|
319 else
|
|
320 hi def link rubyIdentifier NONE
|
|
321 endif
|
|
322 hi def link rubyClassVariable rubyIdentifier
|
|
323 hi def link rubyConstant Type
|
|
324 hi def link rubyGlobalVariable rubyIdentifier
|
|
325 hi def link rubyBlockParameter rubyIdentifier
|
|
326 hi def link rubyInstanceVariable rubyIdentifier
|
|
327 hi def link rubyPredefinedIdentifier rubyIdentifier
|
|
328 hi def link rubyPredefinedConstant rubyPredefinedIdentifier
|
|
329 hi def link rubyPredefinedVariable rubyPredefinedIdentifier
|
|
330 hi def link rubySymbol Constant
|
|
331 hi def link rubyKeyword Keyword
|
|
332 hi def link rubyOperator Operator
|
|
333 hi def link rubyPseudoOperator rubyOperator
|
|
334 hi def link rubyBeginEnd Statement
|
|
335 hi def link rubyAccess Statement
|
|
336 hi def link rubyAttribute Statement
|
|
337 hi def link rubyEval Statement
|
|
338 hi def link rubyPseudoVariable Constant
|
7
|
339
|
1190
|
340 hi def link rubyComment Comment
|
|
341 hi def link rubyData Comment
|
|
342 hi def link rubyDataDirective Delimiter
|
|
343 hi def link rubyDocumentation Comment
|
1668
|
344 hi def link rubyTodo Todo
|
|
345
|
2225
|
346 hi def link rubyQuoteEscape rubyStringEscape
|
1668
|
347 hi def link rubyStringEscape Special
|
1190
|
348 hi def link rubyInterpolationDelimiter Delimiter
|
|
349 hi def link rubyNoInterpolation rubyString
|
|
350 hi def link rubySharpBang PreProc
|
|
351 hi def link rubyRegexpDelimiter rubyStringDelimiter
|
1668
|
352 hi def link rubySymbolDelimiter rubyStringDelimiter
|
1190
|
353 hi def link rubyStringDelimiter Delimiter
|
1668
|
354 hi def link rubyString String
|
|
355 hi def link rubyRegexpEscape rubyRegexpSpecial
|
|
356 hi def link rubyRegexpQuantifier rubyRegexpSpecial
|
|
357 hi def link rubyRegexpAnchor rubyRegexpSpecial
|
|
358 hi def link rubyRegexpDot rubyRegexpCharClass
|
|
359 hi def link rubyRegexpCharClass rubyRegexpSpecial
|
|
360 hi def link rubyRegexpSpecial Special
|
|
361 hi def link rubyRegexpComment Comment
|
1190
|
362 hi def link rubyRegexp rubyString
|
7
|
363
|
1190
|
364 hi def link rubyInvalidVariable Error
|
|
365 hi def link rubyError Error
|
|
366 hi def link rubySpaceError rubyError
|
7
|
367
|
|
368 let b:current_syntax = "ruby"
|
|
369
|
1668
|
370 " vim: nowrap sw=2 sts=2 ts=8 noet:
|