Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 325 lines (281 sloc) 23.094 kb
4984d5a @gsinclair Initial revision
gsinclair authored
1 " Vim syntax file
ad3a6a9 @dkearns add Release-Coordinator header line and remove GPL license
dkearns authored
2 " Language: Ruby
3 " Maintainer: Doug Kearns <dougkearns@gmail.com>
4 " Info: $Id$
5 " URL: http://vim-ruby.rubyforge.org
6 " Anon CVS: See above site
7 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
f58baf6 @dkearns retab the header sections
dkearns authored
8 " ----------------------------------------------------------------------------
11eb8c0 @gsinclair Included licence, disclaimer, $, website
gsinclair authored
9 "
4984d5a @gsinclair Initial revision
gsinclair authored
10 " Previous Maintainer: Mirko Nasato
11 " Thanks to perl.vim authors, and to Reimer Behrends. :-) (MN)
f58baf6 @dkearns retab the header sections
dkearns authored
12 " ----------------------------------------------------------------------------
4984d5a @gsinclair Initial revision
gsinclair authored
13
7c94a16 @dkearns remove the Vim version 5 compatibility code
dkearns authored
14 if exists("b:current_syntax")
cb609f1 @dkearns rename the rubyNoDoBlock, rubyCaseBlock, rubyConditionalBlock, and
dkearns authored
15 finish
4984d5a @gsinclair Initial revision
gsinclair authored
16 endif
17
20dec8c @dkearns check for folding feature before setting foldmethod to syntax
dkearns authored
18 if has("folding") && exists("ruby_fold")
ea33ec5 @dkearns add ruby_fold variable to control setting foldmethod
dkearns authored
19 setlocal foldmethod=syntax
20 endif
21
70e0ed4 @dkearns add configurable highlighting of whitespace errors
dkearns authored
22 if exists("ruby_space_errors")
23 if !exists("ruby_no_trail_space_error")
24 syn match rubySpaceError display excludenl "\s\+$"
25 endif
26 if !exists("ruby_no_tab_space_error")
27 syn match rubySpaceError display " \+\t"me=e-1
28 endif
29 endif
30
02e440c @dkearns fold all multiline strings
dkearns authored
31 " Operators
1293977 @dkearns add initial support for highlighting 'operators'
dkearns authored
32 if exists("ruby_operators")
c9b6e4e @dkearns highlight the scope and range operators when ruby_operators is set; simp...
dkearns authored
33 syn match rubyOperator "\%([~!^&|*/%+-]\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|=\@<!>\|\*\*\|\.\.\.\|\.\.\|::\)"
8dd3e30 @dkearns when ruby_operators is set don't match '>' in '=>'; fix some minor bugs ...
dkearns authored
34 syn match rubyPseudoOperator "\%(-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!=\)"
35 syn region rubyBracketOperator matchgroup=rubyOperator start="\%([_[:lower:]]\w*[?!=]\=\|[})]\)\@<=\[\s*" end="\s*]" contains=TOP
1293977 @dkearns add initial support for highlighting 'operators'
dkearns authored
36 endif
37
4984d5a @gsinclair Initial revision
gsinclair authored
38 " Expression Substitution and Backslash Notation
8aea850 @dkearns :retab! syntax/ruby.vim to save a few bytes
dkearns authored
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
962aa43 @dkearns reorganise string interpolation syntax groups
dkearns authored
41
42 syn region rubyInterpolation matchgroup=rubyInterpolationDelimiter start="#{" end="}" contained contains=TOP
ec81116 @dkearns add rubyPredefinedVariable to short-form rubyInterpolation's contains li...
dkearns authored
43 syn match rubyInterpolation "#\%(\$\|@@\=\)\w\+" display contained contains=rubyInterpolationDelimiter,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable,rubyPredefinedVariable
8aea850 @dkearns :retab! syntax/ruby.vim to save a few bytes
dkearns authored
44 syn match rubyInterpolationDelimiter "#\ze\%(\$\|@@\=\)\w\+" display contained
ad4ede5 @tpope Punctuation variables in strings
tpope authored
45 syn match rubyInterpolation "#\$\%(-\w\|\W\)" display contained contains=rubyInterpolationDelimiter,rubyPredefinedVariable,rubyInvalidVariable
46 syn match rubyInterpolationDelimiter "#\ze\$\%(-\w\|\W\)" display contained
962aa43 @dkearns reorganise string interpolation syntax groups
dkearns authored
47 syn region rubyNoInterpolation start="\\#{" end="}" contained
48 syn match rubyNoInterpolation "\\#{" display contained
49 syn match rubyNoInterpolation "\\#\%(\$\|@@\=\)\w\+" display contained
ad4ede5 @tpope Punctuation variables in strings
tpope authored
50 syn match rubyNoInterpolation "\\#\$\W" display contained
4cdebce @dkearns match rubyNested*, and rubyDelimEscape as transparent items
dkearns authored
51
52 syn match rubyDelimEscape "\\[(<{\[)>}\]]" transparent display contained contains=NONE
53
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
b2c253f @dkearns add rubyArrayLiteral syntax group for folding multiline array literals
dkearns authored
57 if exists("ruby_operators")
58 syn region rubyNestedSquareBrackets start="\[" end="\]" skip="\\\\\|\\\]" transparent contained contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape
59 else
60 syn region rubyNestedSquareBrackets start="\[" end="\]" skip="\\\\\|\\\]" transparent containedin=rubyArrayLiteral contained contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape
61 endif
ff4b8d7 @dkearns highlight escaped string interpolation correctly
dkearns authored
62
962aa43 @dkearns reorganise string interpolation syntax groups
dkearns authored
63 syn cluster rubyStringSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyEscape
4cdebce @dkearns match rubyNested*, and rubyDelimEscape as transparent items
dkearns authored
64 syn cluster rubyExtendedStringSpecial contains=@rubyStringSpecial,rubyNestedParentheses,rubyNestedCurlyBraces,rubyNestedAngleBrackets,rubyNestedSquareBrackets
4984d5a @gsinclair Initial revision
gsinclair authored
65
66 " Numbers and ASCII Codes
83fd326 @tpope Minor ruby syntax fixes
tpope authored
67 syn match rubyASCIICode "\%(\w\|[]})\"'/]\)\@<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)\)"
158f6dc @dkearns add support for the new decimal and octal base indicators
dkearns authored
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
a98ee81 @dkearns create rubyPseudoVariable syntax group
dkearns authored
72 syn match rubyFloat "\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\.\d\+\%(_\d\+\)*\>" display
dac90ca @dkearns link rubyNoInterpolation to rubyString and merge integer groups into rub...
dkearns authored
73 syn match rubyFloat "\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\%(\.\d\+\%(_\d\+\)*\)\=\%([eE][-+]\=\d\+\%(_\d\+\)*\)\>" display
4984d5a @gsinclair Initial revision
gsinclair authored
74
fd3562f @dkearns create Special Methods section and add ruby_no_special_methods variable
dkearns authored
75 " Identifiers
72e413c @dkearns match rubyConstant and rubyLocalVariableOrMethod with a leading word bou...
dkearns authored
76 syn match rubyLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent
e272936 @dkearns minor refinement of rubyBlockParameter syntax pattern
dkearns authored
77 syn match rubyBlockArgument "&[_[:lower:]][_[:alnum:]]" contains=NONE display transparent
4984d5a @gsinclair Initial revision
gsinclair authored
78
38ab5a9 @tpope syntax/ruby.vim: highlight correctly if iskeyword includes a colon
tpope authored
79 syn match rubyConstant "\%(\%([.@$]\@<!\.\)\@<!\<\|::\)\_s*\zs\u\w*\%(\>\|::\)\@=\%(\s*(\)\@!"
e272936 @dkearns minor refinement of rubyBlockParameter syntax pattern
dkearns authored
80 syn match rubyClassVariable "@@\h\w*" display
81 syn match rubyInstanceVariable "@\h\w*" display
a25b182 @dkearns move ruby_no_identifiers test to the default highlighting block
dkearns authored
82 syn match rubyGlobalVariable "$\%(\h\w*\|-.\)"
83fd326 @tpope Minor ruby syntax fixes
tpope authored
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
c9b6e4e @dkearns highlight the scope and range operators when ruby_operators is set; simp...
dkearns authored
89
90 syn match rubyBlockParameter "\h\w*" contained
91 syn region rubyBlockParameterList start="\%(\%(\<do\>\|{\)\s*\)\@<=|" end="|" oneline display contains=rubyBlockParameter
a25b182 @dkearns move ruby_no_identifiers test to the default highlighting block
dkearns authored
92
ad4ede5 @tpope Punctuation variables in strings
tpope authored
93 syn match rubyInvalidVariable "$[^ A-Za-z-]"
a25b182 @dkearns move ruby_no_identifiers test to the default highlighting block
dkearns authored
94 syn match rubyPredefinedVariable #$[!$&"'*+,./0:;<=>?@\`~1-9]#
8d11a6c @dkearns add $LOADED_FEATURES and $PROGRAM_NAME to rubyPredefinedVariable
dkearns authored
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
a25b182 @dkearns move ruby_no_identifiers test to the default highlighting block
dkearns authored
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\)\>"
4984d5a @gsinclair Initial revision
gsinclair authored
105
927493e @dkearns remove Vim 5.x sections and simplify general delimited input syntax grou...
dkearns authored
106 " Normal Regular Expression
83fd326 @tpope Minor ruby syntax fixes
tpope authored
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
4984d5a @gsinclair Initial revision
gsinclair authored
109
110 " Normal String and Shell Command Output
02e440c @dkearns fold all multiline strings
dkearns authored
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
4984d5a @gsinclair Initial revision
gsinclair authored
114
927493e @dkearns remove Vim 5.x sections and simplify general delimited input syntax grou...
dkearns authored
115 " Generalized Regular Expression
83fd326 @tpope Minor ruby syntax fixes
tpope authored
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
927493e @dkearns remove Vim 5.x sections and simplify general delimited input syntax grou...
dkearns authored
121
122 " Generalized Single Quoted String, Symbol and Array of Strings
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored
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
927493e @dkearns remove Vim 5.x sections and simplify general delimited input syntax grou...
dkearns authored
133
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
ff4b8d7 @dkearns highlight escaped string interpolation correctly
dkearns authored
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
4cdebce @dkearns match rubyNested*, and rubyDelimEscape as transparent items
dkearns authored
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
4984d5a @gsinclair Initial revision
gsinclair authored
142
143 " Here Document
83fd326 @tpope Minor ruby syntax fixes
tpope authored
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
abdd731 @dkearns improve highlighting of heredocs used as method arguments
dkearns authored
148
83fd326 @tpope Minor ruby syntax fixes
tpope authored
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
9f43f44 @dkearns remove accidently included nextgroup arg in 'heredoc' syntax group defin...
dkearns authored
153
83fd326 @tpope Minor ruby syntax fixes
tpope authored
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
abdd731 @dkearns improve highlighting of heredocs used as method arguments
dkearns authored
158
1655fec @dkearns general improvements to eRuby highlighting
dkearns authored
159 if exists('main_syntax') && main_syntax == 'eruby'
9f60b4b @dkearns make the use of 'ruby_no_expensive' local to the buffer for eruby files
dkearns authored
160 let b:ruby_no_expensive = 1
1655fec @dkearns general improvements to eRuby highlighting
dkearns authored
161 end
162
dfbd166 @tpope syntax/ruby.vim
tpope authored
163 syn match rubyAliasDeclaration "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable nextgroup=rubyAliasDeclaration2 skipwhite
164 syn match rubyAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable
6f230af @dkearns make sure 'class << self' is always highlighted
dkearns authored
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
06da40e @tpope Method highlighting
tpope authored
168 syn match rubyFunction "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:].:?!=]\@!" contained containedin=rubyMethodDeclaration
169 syn match rubyFunction "\%(\s\|^\)\@<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2
75634b9 @dkearns highlight == and & 'operator' redefinitions properly
dkearns authored
170 syn match rubyFunction "\%([[:space:].]\|^\)\@<=\%(\[\]=\=\|\*\*\|[+-]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|==\|=\~\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration
cb609f1 @dkearns rename the rubyNoDoBlock, rubyCaseBlock, rubyConditionalBlock, and
dkearns authored
171
172 " Expensive Mode - match 'end' with the appropriate opening keyword for syntax
173 " based folding and special highlighting of module/class/method definitions
9f60b4b @dkearns make the use of 'ruby_no_expensive' local to the buffer for eruby files
dkearns authored
174 if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive")
8aea850 @dkearns :retab! syntax/ruby.vim to save a few bytes
dkearns authored
175 syn match rubyDefine "\<alias\>" nextgroup=rubyAliasDeclaration skipwhite skipnl
7a429a5 @tpope indent/eruby.vim and syntax/ruby.vim
tpope authored
176 syn match rubyDefine "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl
8aea850 @dkearns :retab! syntax/ruby.vim to save a few bytes
dkearns authored
177 syn match rubyClass "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl
7a429a5 @tpope indent/eruby.vim and syntax/ruby.vim
tpope authored
178 syn match rubyModule "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl
9a0d742 @dkearns highlight methods named "end" when the definition is distributed over mu...
dkearns authored
179 syn region rubyBlock start="\<def\>" matchgroup=rubyDefine end="\%(\<def\_s\+\)\@<!\<end\>" contains=TOP fold
7a429a5 @tpope indent/eruby.vim and syntax/ruby.vim
tpope authored
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
4984d5a @gsinclair Initial revision
gsinclair authored
182
1454fb5 @dkearns prevent the optional 'do' in loop constructs from being matched as the b...
dkearns authored
183 " modifiers
d7bcd67 @dkearns add rubyConditionalModifier and rubyRepeatModifier syntax groups for
dkearns authored
184 syn match rubyConditionalModifier "\<\%(if\|unless\)\>" display
185 syn match rubyRepeatModifier "\<\%(while\|until\)\>" display
4984d5a @gsinclair Initial revision
gsinclair authored
186
7a429a5 @tpope indent/eruby.vim and syntax/ruby.vim
tpope authored
187 syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=TOP fold
b2c253f @dkearns add rubyArrayLiteral syntax group for folding multiline array literals
dkearns authored
188 " curly bracket block or hash literal
8fc5e15 @dkearns remove accidentally included matchgroup from rubyArrayLiteral
dkearns authored
189 syn region rubyCurlyBlock start="{" end="}" contains=TOP fold
96a1917 @dkearns add matchgroup to rubyArrayLiteral so that contained square brackets do ...
dkearns authored
190 syn region rubyArrayLiteral matchgroup=rubyArrayDelimiter start="\%(\w\|[\]})]\)\@<!\[" end="]" contains=TOP fold
4984d5a @gsinclair Initial revision
gsinclair authored
191
cb609f1 @dkearns rename the rubyNoDoBlock, rubyCaseBlock, rubyConditionalBlock, and
dkearns authored
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
83fd326 @tpope Minor ruby syntax fixes
tpope authored
195 syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!?]\)\s*\)\@<=\%(if\|unless\)\>" end="\<end\>" contains=TOP fold
cb609f1 @dkearns rename the rubyNoDoBlock, rubyCaseBlock, rubyConditionalBlock, and
dkearns authored
196
197 syn keyword rubyConditional then else when contained containedin=rubyCaseExpression
198 syn keyword rubyConditional then else elsif contained containedin=rubyConditionalExpression
4984d5a @gsinclair Initial revision
gsinclair authored
199
cb609f1 @dkearns rename the rubyNoDoBlock, rubyCaseBlock, rubyConditionalBlock, and
dkearns authored
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
4984d5a @gsinclair Initial revision
gsinclair authored
203
204 if !exists("ruby_minlines")
205 let ruby_minlines = 50
206 endif
207 exec "syn sync minlines=" . ruby_minlines
208
fd3562f @dkearns create Special Methods section and add ruby_no_special_methods variable
dkearns authored
209 else
8aea850 @dkearns :retab! syntax/ruby.vim to save a few bytes
dkearns authored
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
7a429a5 @tpope indent/eruby.vim and syntax/ruby.vim
tpope authored
213 syn keyword rubyControl case begin do for if unless while until else elsif then when end
5eb3fb0 @tpope syntax/ruby.vim changes
tpope authored
214 syn keyword rubyKeyword alias
fd3562f @dkearns create Special Methods section and add ruby_no_special_methods variable
dkearns authored
215 endif
4984d5a @gsinclair Initial revision
gsinclair authored
216
217 " Keywords
365e82e @dkearns match $deferr explicitly and add support for several more 'special' meth...
dkearns authored
218 " Note: the following keywords have already been defined:
7182ecf @dkearns simplify the rubyData pattern
dkearns authored
219 " begin case class def do end for if module unless until while
7a429a5 @tpope indent/eruby.vim and syntax/ruby.vim
tpope authored
220 syn keyword rubyControl and break ensure in next not or redo rescue retry return
a98ee81 @dkearns create rubyPseudoVariable syntax group
dkearns authored
221 syn match rubyOperator "\<defined?" display
5eb3fb0 @tpope syntax/ruby.vim changes
tpope authored
222 syn keyword rubyKeyword super undef yield
a98ee81 @dkearns create rubyPseudoVariable syntax group
dkearns authored
223 syn keyword rubyBoolean true false
224 syn keyword rubyPseudoVariable nil self __FILE__ __LINE__
225 syn keyword rubyBeginEnd BEGIN END
fd3562f @dkearns create Special Methods section and add ruby_no_special_methods variable
dkearns authored
226
227 " Special Methods
228 if !exists("ruby_no_special_methods")
7e4b0f2 @dkearns add support for access control methods (public, protected and private)
dkearns authored
229 syn keyword rubyAccess public protected private
365e82e @dkearns match $deferr explicitly and add support for several more 'special' meth...
dkearns authored
230 syn keyword rubyAttribute attr attr_accessor attr_reader attr_writer
d9c422e @dkearns match and highlight exit! as a 'special' method
dkearns authored
231 syn match rubyControl "\<\%(exit!\|\%(abort\|at_exit\|exit\|fork\|loop\|trap\)\>\)"
ec45322 @dkearns replace spaces with tabs, where possible, to reduce file sizes as reques...
dkearns authored
232 syn keyword rubyEval eval class_eval instance_eval module_eval
365e82e @dkearns match $deferr explicitly and add support for several more 'special' meth...
dkearns authored
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
fd3562f @dkearns create Special Methods section and add ruby_no_special_methods variable
dkearns authored
236 endif
4984d5a @gsinclair Initial revision
gsinclair authored
237
238 " Comments and Documentation
67ca3d8 @dkearns improve support for symbols, integers and floats
dkearns authored
239 syn match rubySharpBang "\%^#!.*" display
621c5b0 @tpope OPTIMIZE in rubyTodo
tpope authored
240 syn keyword rubyTodo FIXME NOTE TODO OPTIMIZE XXX contained
70e0ed4 @dkearns add configurable highlighting of whitespace errors
dkearns authored
241 syn match rubyComment "#.*" contains=rubySharpBang,rubySpaceError,rubyTodo,@Spell
2f2f0de @dkearns make folding of comments configurable via the ruby_no_comment_fold varia...
dkearns authored
242 if !exists("ruby_no_comment_fold")
b4efb82 @dkearns use a region for the rubyMultiLineComment syntax group instead of a mult...
dkearns authored
243 syn region rubyMultilineComment start="\%(\%(^\s*#.*\n\)\@<!\%(^\s*#.*\n\)\)\%(\(^\s*#.*\n\)\{1,}\)\@=" end="\%(^\s*#.*\n\)\@<=\%(^\s*#.*\n\)\%(^\s*#\)\@!" contains=rubyComment transparent fold keepend
f5f62e0 @dkearns allow text to appear after, and on the same line, as '=begin' in
dkearns authored
244 syn region rubyDocumentation start="^=begin\ze\%(\s.*\)\=$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell fold
336f997 @dkearns make sure rubyDocumentation is highlighted even if ruby_no_comment_fold ...
dkearns authored
245 else
8aea850 @dkearns :retab! syntax/ruby.vim to save a few bytes
dkearns authored
246 syn region rubyDocumentation start="^=begin\s*$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell
2f2f0de @dkearns make folding of comments configurable via the ruby_no_comment_fold varia...
dkearns authored
247 endif
4984d5a @gsinclair Initial revision
gsinclair authored
248
4cdebce @dkearns match rubyNested*, and rubyDelimEscape as transparent items
dkearns authored
249 " Note: this is a hack to prevent 'keywords' being highlighted as such when called as methods with an explicit receiver
8ae54b2 @dkearns replace all syntax patterns surrounded by \(\) with \%(\)
dkearns authored
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
254
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
4984d5a @gsinclair Initial revision
gsinclair authored
261
262 " __END__ Directive
7182ecf @dkearns simplify the rubyData pattern
dkearns authored
263 syn region rubyData matchgroup=rubyDataDirective start="^__END__$" end="\%$" fold
4984d5a @gsinclair Initial revision
gsinclair authored
264
7c94a16 @dkearns remove the Vim version 5 compatibility code
dkearns authored
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
283 else
284 hi def link rubyIdentifier NONE
4984d5a @gsinclair Initial revision
gsinclair authored
285 endif
7c94a16 @dkearns remove the Vim version 5 compatibility code
dkearns authored
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
303
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
317
ad4ede5 @tpope Punctuation variables in strings
tpope authored
318 hi def link rubyInvalidVariable Error
7c94a16 @dkearns remove the Vim version 5 compatibility code
dkearns authored
319 hi def link rubyError Error
320 hi def link rubySpaceError rubyError
4984d5a @gsinclair Initial revision
gsinclair authored
321
322 let b:current_syntax = "ruby"
323
7a429a5 @tpope indent/eruby.vim and syntax/ruby.vim
tpope authored
324 " vim: nowrap sw=2 sts=2 ts=8 noet ff=unix:
Something went wrong with that request. Please try again.