Mirror of the Vim source from https://github.com/vim/vim
修訂 | 70ce979e76bc0559c74f19fe61aa77b5a9645c74 (tree) |
---|---|
時間 | 2019-12-10 07:15:04 |
作者 | Bram Moolenaar <Bram@vim....> |
Commiter | Bram Moolenaar |
Update a few runtime files.
Commit: https://github.com/vim/vim/commit/2ed639abdc4000436115f378e28320b7bee38a6e
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Dec 9 23:11:18 2019 +0100
@@ -3,7 +3,7 @@ | ||
3 | 3 | " Maintainer: Mark Guzman <segfault@hasno.info> |
4 | 4 | " URL: https://github.com/vim-ruby/vim-ruby |
5 | 5 | " Release Coordinator: Doug Kearns <dougkearns@gmail.com> |
6 | -" Last Change: 2019 Jan 06 | |
6 | +" Last Change: 2019 Feb 25 | |
7 | 7 | " ---------------------------------------------------------------------------- |
8 | 8 | " |
9 | 9 | " Ruby IRB/Complete author: Keiju ISHITSUKA(keiju@ishitsuka.com) |
@@ -53,6 +53,23 @@ | ||
53 | 53 | endif |
54 | 54 | " }}} configuration failsafe initialization |
55 | 55 | |
56 | +" {{{ regex patterns | |
57 | + | |
58 | +" Regex that defines the start-match for the 'end' keyword. | |
59 | +let s:end_start_regex = | |
60 | + \ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' . | |
61 | + \ '\<\%(module\|class\|if\|for\|while\|until\|case\|unless\|begin' . | |
62 | + \ '\|\%(\K\k*[!?]\?\s\+\)\=def\):\@!\>' . | |
63 | + \ '\|\%(^\|[^.:@$]\)\@<=\<do:\@!\>' | |
64 | + | |
65 | +" Regex that defines the middle-match for the 'end' keyword. | |
66 | +let s:end_middle_regex = '\<\%(ensure\|else\|\%(\%(^\|;\)\s*\)\@<=\<rescue:\@!\>\|when\|elsif\):\@!\>' | |
67 | + | |
68 | +" Regex that defines the end-match for the 'end' keyword. | |
69 | +let s:end_end_regex = '\%(^\|[^.:@$]\)\@<=\<end:\@!\>' | |
70 | + | |
71 | +" }}} regex patterns | |
72 | + | |
56 | 73 | " {{{ vim-side support functions |
57 | 74 | let s:rubycomplete_debug = 0 |
58 | 75 |
@@ -103,7 +120,7 @@ | ||
103 | 120 | endif |
104 | 121 | |
105 | 122 | let curpos = getpos(".") |
106 | - let [enum,ecol] = searchpairpos( crex, '', '\(end\|}\)', 'W' ) | |
123 | + let [enum,ecol] = searchpairpos( s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'W' ) | |
107 | 124 | call cursor(lastpos[1], lastpos[2]) |
108 | 125 | |
109 | 126 | if lnum > enum |
@@ -128,19 +145,28 @@ | ||
128 | 145 | return ret |
129 | 146 | endfunction |
130 | 147 | |
148 | +function! s:IsInComment(pos) | |
149 | + let stack = synstack(a:pos[0], a:pos[1]) | |
150 | + if !empty(stack) | |
151 | + return synIDattr(stack[0], 'name') =~ 'ruby\%(.*Comment\|Documentation\)' | |
152 | + else | |
153 | + return 0 | |
154 | + endif | |
155 | +endfunction | |
156 | + | |
131 | 157 | function! s:GetRubyVarType(v) |
132 | 158 | let stopline = 1 |
133 | 159 | let vtp = '' |
134 | - let pos = getpos('.') | |
160 | + let curpos = getpos('.') | |
135 | 161 | let sstr = '^\s*#\s*@var\s*'.escape(a:v, '*').'\>\s\+[^ \t]\+\s*$' |
136 | 162 | let [lnum,lcol] = searchpos(sstr,'nb',stopline) |
137 | 163 | if lnum != 0 && lcol != 0 |
138 | - call setpos('.',pos) | |
164 | + call setpos('.',curpos) | |
139 | 165 | let str = getline(lnum) |
140 | 166 | let vtp = substitute(str,sstr,'\1','') |
141 | 167 | return vtp |
142 | 168 | endif |
143 | - call setpos('.',pos) | |
169 | + call setpos('.',curpos) | |
144 | 170 | let ctors = '\(now\|new\|open\|get_instance' |
145 | 171 | if exists('g:rubycomplete_rails') && g:rubycomplete_rails == 1 && s:rubycomplete_rails_loaded == 1 |
146 | 172 | let ctors = ctors.'\|find\|create' |
@@ -150,9 +176,13 @@ | ||
150 | 176 | |
151 | 177 | let fstr = '=\s*\([^ \t]\+.' . ctors .'\>\|[\[{"''/]\|%[xwQqr][(\[{@]\|[A-Za-z0-9@:\-()\.]\+...\?\|lambda\|&\)' |
152 | 178 | let sstr = ''.escape(a:v, '*').'\>\s*[+\-*/]*'.fstr |
153 | - let [lnum,lcol] = searchpos(sstr,'nb',stopline) | |
154 | - if lnum != 0 && lcol != 0 | |
155 | - let str = matchstr(getline(lnum),fstr,lcol) | |
179 | + let pos = searchpos(sstr,'bW') | |
180 | + while pos != [0,0] && s:IsInComment(pos) | |
181 | + let pos = searchpos(sstr,'bW') | |
182 | + endwhile | |
183 | + if pos != [0,0] | |
184 | + let [lnum, col] = pos | |
185 | + let str = matchstr(getline(lnum),fstr,col) | |
156 | 186 | let str = substitute(str,'^=\s*','','') |
157 | 187 | |
158 | 188 | call setpos('.',pos) |
@@ -174,7 +204,7 @@ | ||
174 | 204 | end |
175 | 205 | return '' |
176 | 206 | endif |
177 | - call setpos('.',pos) | |
207 | + call setpos('.',curpos) | |
178 | 208 | return '' |
179 | 209 | endfunction |
180 | 210 |
@@ -671,11 +701,10 @@ | ||
671 | 701 | methods.delete_if { |c| c.match( /'/ ) } |
672 | 702 | end |
673 | 703 | |
674 | - when /^::([A-Z][^:\.\(]*)$/ # Absolute Constant or class methods | |
704 | + when /^::([A-Z][^:\.\(]*)?$/ # Absolute Constant or class methods | |
675 | 705 | dprint "const or cls" |
676 | 706 | receiver = $1 |
677 | - methods = Object.constants | |
678 | - methods.grep(/^#{receiver}/).collect{|e| "::" + e} | |
707 | + methods = Object.constants.collect{ |c| c.to_s }.grep(/^#{receiver}/) | |
679 | 708 | |
680 | 709 | when /^(((::)?[A-Z][^:.\(]*)+?)::?([^:.]*)$/ # Constant or class methods |
681 | 710 | receiver = $1 |
@@ -684,13 +713,13 @@ | ||
684 | 713 | load_buffer_class( receiver ) |
685 | 714 | load_buffer_module( receiver ) |
686 | 715 | begin |
687 | - classes = eval("#{receiver}.constants") | |
688 | - #methods = eval("#{receiver}.methods") | |
716 | + constants = eval("#{receiver}.constants").collect{ |c| c.to_s }.grep(/^#{message}/) | |
717 | + methods = eval("#{receiver}.methods").collect{ |m| m.to_s }.grep(/^#{message}/) | |
689 | 718 | rescue Exception |
690 | 719 | dprint "exception: %s" % $! |
720 | + constants = [] | |
691 | 721 | methods = [] |
692 | 722 | end |
693 | - methods.grep(/^#{message}/).collect{|e| receiver + "::" + e} | |
694 | 723 | |
695 | 724 | when /^(:[^:.]+)\.([^.]*)$/ # Symbol |
696 | 725 | dprint "symbol" |
@@ -41,7 +41,6 @@ | ||
41 | 41 | is performed and echoed onto the display. |
42 | 42 | |
43 | 43 | :LogiPatFlags {search flags} *LogiPat-flags* |
44 | - :LogiPatFlags {search flags} | |
45 | 44 | LogiPat uses the |search()| command. The flags |
46 | 45 | passed to that call to search() may be specified |
47 | 46 | by the :LogiPatFlags command. |
@@ -105,7 +104,7 @@ | ||
105 | 104 | |
106 | 105 | |
107 | 106 | ============================================================================== |
108 | -3. LogiPat History *logiPat-history* | |
107 | +5. LogiPat History *logiPat-history* | |
109 | 108 | |
110 | 109 | v4 Jun 22, 2015 * LogiPat has been picked up by Bram M for standard |
111 | 110 | plugin distribution; hence the name change |
@@ -1,4 +1,4 @@ | ||
1 | -*pi_netrw.txt* For Vim version 8.1. Last change: 2019 Nov 30 | |
1 | +*pi_netrw.txt* For Vim version 8.1. Last change: 2019 Dec 09 | |
2 | 2 | |
3 | 3 | ------------------------------------------------ |
4 | 4 | NETRW REFERENCE MANUAL by Charles E. Campbell |
@@ -1184,7 +1184,7 @@ | ||
1184 | 1184 | *.netrwbook* |
1185 | 1185 | Bookmarks are retained in between sessions of vim in a file called .netrwbook |
1186 | 1186 | as a |List|, which is typically stored in the first directory on the user's |
1187 | -|'runtimepath'|; entries are kept in sorted order. | |
1187 | +runtimepath'; entries are kept in sorted order. | |
1188 | 1188 | |
1189 | 1189 | If there are marked files and/or directories, mb will add them to the bookmark |
1190 | 1190 | list. |
@@ -1,4 +1,4 @@ | ||
1 | -*todo.txt* For Vim version 8.1. Last change: 2019 Dec 07 | |
1 | +*todo.txt* For Vim version 8.1. Last change: 2019 Dec 08 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -118,6 +118,8 @@ | ||
118 | 118 | E453, E454, E460, E489, E491, E565, E578, E610, E611, E653, |
119 | 119 | E654, E856, E857, E860, E861, E863, E889, E900 |
120 | 120 | |
121 | +Patch to move duplicated code to a function. (Yegappan Lakshmanan, #5330) | |
122 | + | |
121 | 123 | Running test_gui and test_gui_init with Motif sometimes kills the window |
122 | 124 | manager. Problem with Motif? Now test_gui crashes in submenu_change(). |
123 | 125 | Athena is OK. |
@@ -1,4 +1,4 @@ | ||
1 | -*version8.txt* For Vim version 8.1. Last change: 2019 Dec 08 | |
1 | +*version8.txt* For Vim version 8.1. Last change: 2019 Dec 09 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -25831,14 +25831,14 @@ | ||
25831 | 25831 | Text properties *new-text-properties* |
25832 | 25832 | --------------- |
25833 | 25833 | |
25834 | -Text properties give a plugin author flexibility what to highlight. This can | |
25835 | -be used with an external asynchronous parser to do syntax highlighting. Or | |
25836 | -to highlight text in a popup window. The text properties stick with the text | |
25837 | -when characters are deleted or inserted, which makes them also useful as text | |
25838 | -markers. See |text-properties|. | |
25834 | +Text properties give a plugin author flexibility about what to highlight. | |
25835 | +This can be used with an external asynchronous parser to do syntax | |
25836 | +highlighting. Or to highlight text in a popup window. The text properties | |
25837 | +stick with the text when characters are deleted or inserted, which makes them | |
25838 | +also useful as text markers. See |text-properties|. | |
25839 | 25839 | |
25840 | 25840 | The listener functions have been added to report text changes to a server so |
25841 | -that it can dynamically update highligting, mark syntax errors and the like. | |
25841 | +that it can dynamically update highlighting, mark syntax errors and the like. | |
25842 | 25842 | See |listener_add()|. |
25843 | 25843 | |
25844 | 25844 |
@@ -39746,7 +39746,7 @@ | ||
39746 | 39746 | |
39747 | 39747 | Patch 8.1.2198 |
39748 | 39748 | Problem: Crash when using :center in autocommand. |
39749 | -Solution: Bail out early for an empty line. (Dominique pelle, closes #5095) | |
39749 | +Solution: Bail out early for an empty line. (Dominique Pelle, closes #5095) | |
39750 | 39750 | Files: src/ex_cmds.c, src/testdir/test_textformat.vim |
39751 | 39751 | |
39752 | 39752 | Patch 8.1.2199 |
@@ -40610,7 +40610,7 @@ | ||
40610 | 40610 | Files: src/quickfix.c, src/testdir/test_quickfix.vim |
40611 | 40611 | |
40612 | 40612 | Patch 8.1.2341 |
40613 | -Problem: Not so easy to interrupt a script programatically. | |
40613 | +Problem: Not so easy to interrupt a script programmatically. | |
40614 | 40614 | Solution: Add the interrupt() function. (Yasuhiro Matsumoto, closes #2834) |
40615 | 40615 | Files: runtime/doc/eval.txt, src/evalfunc.c, src/ex_eval.c, |
40616 | 40616 | src/testdir/Make_all.mak, src/testdir/test_interrupt.vim |
@@ -41039,7 +41039,7 @@ | ||
41039 | 41039 | Files: src/term.c, src/os_unix.c, src/register.c |
41040 | 41040 | |
41041 | 41041 | Patch 8.1.2407 |
41042 | -Problem: proto file and dependenciess outdated. | |
41042 | +Problem: proto file and dependencies outdated. | |
41043 | 41043 | Solution: Update proto files and dependencies. |
41044 | 41044 | Files: src/Makefile, src/proto/bufwrite.pro, src/proto/cmdhist.pro, |
41045 | 41045 | src/proto/optionstr.pro, src/proto/popupwin.pro, |
@@ -3,7 +3,7 @@ | ||
3 | 3 | " Maintainer: Tim Pope <vimNOSPAM@tpope.org> |
4 | 4 | " URL: https://github.com/vim-ruby/vim-ruby |
5 | 5 | " Release Coordinator: Doug Kearns <dougkearns@gmail.com> |
6 | -" Last Change: 2019 Jan 06 | |
6 | +" Last Change: 2019 Nov 06 | |
7 | 7 | |
8 | 8 | if (exists("b:did_ftplugin")) |
9 | 9 | finish |
@@ -24,20 +24,20 @@ | ||
24 | 24 | let b:match_ignorecase = 0 |
25 | 25 | |
26 | 26 | let b:match_words = |
27 | - \ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|def\|begin\)\>=\@!' . | |
27 | + \ '{\|\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|def\|=\@<!begin\)\>=\@!' . | |
28 | 28 | \ ':' . |
29 | 29 | \ '\<\%(else\|elsif\|ensure\|when\|rescue\|break\|redo\|next\|retry\)\>' . |
30 | 30 | \ ':' . |
31 | - \ '\%(^\|[^.\:@$]\)\@<=\<end\:\@!\>' . | |
32 | - \ ',{:},\[:\],(:)' | |
31 | + \ '}\|\%(^\|[^.\:@$=]\)\@<=\<end\:\@!\>' . | |
32 | + \ ',^=begin\>:^=end\>,' . | |
33 | + \ ',\[:\],(:)' | |
33 | 34 | |
34 | 35 | let b:match_skip = |
35 | 36 | \ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" . |
36 | - \ "\\<ruby\\%(String\\|StringDelimiter\\|ASCIICode\\|Escape\\|" . | |
37 | - \ "Regexp\\|RegexpDelimiter\\|" . | |
38 | - \ "Interpolation\\|NoInterpolation\\|Comment\\|Documentation\\|" . | |
39 | - \ "ConditionalModifier\\|RepeatModifier\\|OptionalDo\\|" . | |
40 | - \ "Function\\|BlockArgument\\|KeywordAsMethod\\|ClassVariable\\|" . | |
37 | + \ "\\<ruby\\%(String\\|.\+Delimiter\\|Character\\|.\+Escape\\|" . | |
38 | + \ "Regexp\\|Interpolation\\|Comment\\|Documentation\\|" . | |
39 | + \ "ConditionalModifier\\|RepeatModifier\\|RescueModifier\\|OptionalDo\\|" . | |
40 | + \ "MethodName\\|BlockArgument\\|KeywordAsMethod\\|ClassVariable\\|" . | |
41 | 41 | \ "InstanceVariable\\|GlobalVariable\\|Symbol\\)\\>'" |
42 | 42 | endif |
43 | 43 |
@@ -87,7 +87,7 @@ | ||
87 | 87 | |
88 | 88 | function! s:build_path(path) abort |
89 | 89 | let path = join(map(copy(a:path), 'v:val ==# "." ? "" : v:val'), ',') |
90 | - if &g:path !~# '\v^\.%(,/%(usr|emx)/include)=,,$' | |
90 | + if &g:path !~# '\v^%(\.,)=%(/%(usr|emx)/include,)=,$' | |
91 | 91 | let path = substitute(&g:path,',,$',',','') . ',' . path |
92 | 92 | endif |
93 | 93 | return path |
@@ -152,7 +152,7 @@ | ||
152 | 152 | function! s:map(mode, flags, map) abort |
153 | 153 | let from = matchstr(a:map, '\S\+') |
154 | 154 | if empty(mapcheck(from, a:mode)) |
155 | - exe a:mode.'map' '<buffer>' a:map | |
155 | + exe a:mode.'map' '<buffer>' a:flags a:map | |
156 | 156 | let b:undo_ftplugin .= '|sil! '.a:mode.'unmap <buffer> '.from |
157 | 157 | endif |
158 | 158 | endfunction |
@@ -311,13 +311,16 @@ | ||
311 | 311 | endfunction |
312 | 312 | |
313 | 313 | function! s:wrap_i(back,forward) abort |
314 | - execute 'norm k'.a:forward | |
314 | + execute 'norm! k' | |
315 | + execute 'norm '.a:forward | |
315 | 316 | let line = line('.') |
316 | 317 | execute 'norm '.a:back |
317 | 318 | if line('.') == line - 1 |
318 | 319 | return s:wrap_a(a:back,a:forward) |
319 | 320 | endif |
320 | - execute 'norm jV'.a:forward.'k' | |
321 | + execute 'norm! jV' | |
322 | + execute 'norm '.a:forward | |
323 | + execute 'norm! k' | |
321 | 324 | endfunction |
322 | 325 | |
323 | 326 | function! s:wrap_a(back,forward) abort |
@@ -330,11 +333,15 @@ | ||
330 | 333 | - |
331 | 334 | endwhile |
332 | 335 | if exists('after') |
333 | - execute 'norm V'.a:forward.'j' | |
336 | + execute 'norm! V' | |
337 | + execute 'norm '.a:forward | |
338 | + execute 'norm! j' | |
334 | 339 | elseif line('.') > 1 && getline(line('.')-1) =~# '^\s*$' |
335 | - execute 'norm kV'.a:forward | |
340 | + execute 'norm! kV' | |
341 | + execute 'norm '.a:forward | |
336 | 342 | else |
337 | - execute 'norm V'.a:forward | |
343 | + execute 'norm! V' | |
344 | + execute 'norm '.a:forward | |
338 | 345 | endif |
339 | 346 | endfunction |
340 | 347 |
@@ -366,7 +373,6 @@ | ||
366 | 373 | endtry |
367 | 374 | let pre = matchstr(strpart(getline('.'), 0, col('.')-1), '.*\f\@<!') |
368 | 375 | let post = matchstr(strpart(getline('.'), col('.')), '\f\@!.*') |
369 | - let ext = getline('.') =~# '^\s*\%(require\%(_relative\)\=\|autoload\)\>' && cfile !~# '\.rb$' ? '.rb' : '' | |
370 | 376 | if s:synid() ==# hlID('rubyConstant') |
371 | 377 | let cfile = substitute(cfile,'\.\w\+[?!=]\=$','','') |
372 | 378 | let cfile = substitute(cfile,'^::','','') |
@@ -375,12 +381,15 @@ | ||
375 | 381 | let cfile = substitute(cfile,'\(\l\|\d\)\(\u\)','\1_\2', 'g') |
376 | 382 | return tolower(cfile) . '.rb' |
377 | 383 | elseif getline('.') =~# '^\s*require_relative\s*\(["'']\).*\1\s*$' |
378 | - let cfile = expand('%:p:h') . '/' . matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . ext | |
384 | + let cfile = expand('%:p:h') . '/' . matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') | |
385 | + let cfile .= cfile !~# '\.rb$' ? '.rb' : '' | |
379 | 386 | elseif getline('.') =~# '^\s*\%(require[( ]\|load[( ]\|autoload[( ]:\w\+,\)\s*\%(::\)\=File\.expand_path(\(["'']\)\.\./.*\1,\s*__FILE__)\s*$' |
380 | 387 | let target = matchstr(getline('.'),'\(["'']\)\.\.\zs/.\{-\}\ze\1') |
381 | - let cfile = expand('%:p:h') . target . ext | |
388 | + let cfile = expand('%:p:h') . target | |
389 | + let cfile .= cfile !~# '\.rb$' ? '.rb' : '' | |
382 | 390 | elseif getline('.') =~# '^\s*\%(require \|load \|autoload :\w\+,\)\s*\(["'']\).*\1\s*$' |
383 | - let cfile = matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . ext | |
391 | + let cfile = matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') | |
392 | + let cfile .= cfile !~# '\.rb$' ? '.rb' : '' | |
384 | 393 | elseif pre.post =~# '\<File.expand_path[( ].*[''"]\{2\}, *__FILE__\>' && cfile =~# '^\.\.' |
385 | 394 | let cfile = expand('%:p:h') . strpart(cfile, 2) |
386 | 395 | else |
@@ -4,7 +4,7 @@ | ||
4 | 4 | " Previous Maintainer: Nikolai Weibull <now at bitwi.se> |
5 | 5 | " URL: https://github.com/vim-ruby/vim-ruby |
6 | 6 | " Release Coordinator: Doug Kearns <dougkearns@gmail.com> |
7 | -" Last Change: 2019 Jan 06 | |
7 | +" Last Change: 2019 Dec 08 | |
8 | 8 | |
9 | 9 | " 0. Initialization {{{1 |
10 | 10 | " ================= |
@@ -51,15 +51,27 @@ | ||
51 | 51 | |
52 | 52 | " Syntax group names that are strings. |
53 | 53 | let s:syng_string = |
54 | - \ ['String', 'Interpolation', 'InterpolationDelimiter', 'NoInterpolation', 'StringEscape'] | |
54 | + \ ['String', 'Interpolation', 'InterpolationDelimiter', 'StringEscape'] | |
55 | 55 | |
56 | 56 | " Syntax group names that are strings or documentation. |
57 | 57 | let s:syng_stringdoc = s:syng_string + ['Documentation'] |
58 | 58 | |
59 | 59 | " Syntax group names that are or delimit strings/symbols/regexes or are comments. |
60 | -let s:syng_strcom = s:syng_stringdoc + | |
61 | - \ ['Regexp', 'RegexpDelimiter', 'RegexpEscape', | |
62 | - \ 'Symbol', 'StringDelimiter', 'ASCIICode', 'Comment'] | |
60 | +let s:syng_strcom = s:syng_stringdoc + [ | |
61 | + \ 'Character', | |
62 | + \ 'Comment', | |
63 | + \ 'HeredocDelimiter', | |
64 | + \ 'PercentRegexpDelimiter', | |
65 | + \ 'PercentStringDelimiter', | |
66 | + \ 'PercentSymbolDelimiter', | |
67 | + \ 'Regexp', | |
68 | + \ 'RegexpCharClass', | |
69 | + \ 'RegexpDelimiter', | |
70 | + \ 'RegexpEscape', | |
71 | + \ 'StringDelimiter', | |
72 | + \ 'Symbol', | |
73 | + \ 'SymbolDelimiter', | |
74 | + \ ] | |
63 | 75 | |
64 | 76 | " Expression used to check whether we should skip a match with searchpair(). |
65 | 77 | let s:skip_expr = |
@@ -69,7 +81,7 @@ | ||
69 | 81 | let s:ruby_indent_keywords = |
70 | 82 | \ '^\s*\zs\<\%(module\|class\|if\|for' . |
71 | 83 | \ '\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue' . |
72 | - \ '\|\%(\K\k*[!?]\?\)\=\s*def\):\@!\>' . | |
84 | + \ '\|\%(\K\k*[!?]\?\s\+\)\=def\):\@!\>' . | |
73 | 85 | \ '\|\%([=,*/%+-]\|<<\|>>\|:\s\)\s*\zs' . |
74 | 86 | \ '\<\%(if\|for\|while\|until\|case\|unless\|begin\):\@!\>' |
75 | 87 |
@@ -83,7 +95,7 @@ | ||
83 | 95 | let s:end_start_regex = |
84 | 96 | \ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' . |
85 | 97 | \ '\<\%(module\|class\|if\|for\|while\|until\|case\|unless\|begin' . |
86 | - \ '\|\%(\K\k*[!?]\?\)\=\s*def\):\@!\>' . | |
98 | + \ '\|\%(\K\k*[!?]\?\s\+\)\=def\):\@!\>' . | |
87 | 99 | \ '\|\%(^\|[^.:@$]\)\@<=\<do:\@!\>' |
88 | 100 | |
89 | 101 | " Regex that defines the middle-match for the 'end' keyword. |
@@ -146,7 +158,7 @@ | ||
146 | 158 | let s:block_continuation_regex = '^\s*[^])}\t ].*'.s:block_regex |
147 | 159 | |
148 | 160 | " Regex that describes a leading operator (only a method call's dot for now) |
149 | -let s:leading_operator_regex = '^\s*[.]' | |
161 | +let s:leading_operator_regex = '^\s*\%(&\=\.\)' | |
150 | 162 | |
151 | 163 | " 2. GetRubyIndent Function {{{1 |
152 | 164 | " ========================= |
@@ -695,7 +707,10 @@ | ||
695 | 707 | |
696 | 708 | " Check if the character at lnum:col is inside a string delimiter |
697 | 709 | function! s:IsInStringDelimiter(lnum, col) abort |
698 | - return s:IsInRubyGroup(['StringDelimiter'], a:lnum, a:col) | |
710 | + return s:IsInRubyGroup( | |
711 | + \ ['HeredocDelimiter', 'PercentStringDelimiter', 'StringDelimiter'], | |
712 | + \ a:lnum, a:col | |
713 | + \ ) | |
699 | 714 | endfunction |
700 | 715 | |
701 | 716 | function! s:IsAssignment(str, pos) abort |
@@ -3,7 +3,7 @@ | ||
3 | 3 | " Maintainer: Doug Kearns <dougkearns@gmail.com> |
4 | 4 | " URL: https://github.com/vim-ruby/vim-ruby |
5 | 5 | " Release Coordinator: Doug Kearns <dougkearns@gmail.com> |
6 | -" Last Change: 2018 Jul 09 | |
6 | +" Last Change: 2019 Jul 13 | |
7 | 7 | " ---------------------------------------------------------------------------- |
8 | 8 | " |
9 | 9 | " Previous Maintainer: Mirko Nasato |
@@ -19,6 +19,11 @@ | ||
19 | 19 | let s:cpo_sav = &cpo |
20 | 20 | set cpo&vim |
21 | 21 | |
22 | +" eRuby Config {{{1 | |
23 | +if exists('main_syntax') && main_syntax == 'eruby' | |
24 | + let b:ruby_no_expensive = 1 | |
25 | +endif | |
26 | + | |
22 | 27 | " Folding Config {{{1 |
23 | 28 | if has("folding") && exists("ruby_fold") |
24 | 29 | setlocal foldmethod=syntax |
@@ -33,6 +38,10 @@ | ||
33 | 38 | \ ) |
34 | 39 | |
35 | 40 | function! s:foldable(...) abort |
41 | + if index(s:foldable_groups, 'NONE') > -1 | |
42 | + return 0 | |
43 | + endif | |
44 | + | |
36 | 45 | if index(s:foldable_groups, 'ALL') > -1 |
37 | 46 | return 1 |
38 | 47 | endif |
@@ -44,9 +53,20 @@ | ||
44 | 53 | endfor |
45 | 54 | |
46 | 55 | return 0 |
47 | -endfunction " }}} | |
56 | +endfunction | |
48 | 57 | |
49 | -syn cluster rubyNotTop contains=@rubyExtendedStringSpecial,@rubyRegexpSpecial,@rubyDeclaration,rubyConditional,rubyExceptional,rubyMethodExceptional,rubyTodo,rubyModuleName,rubyClassName,rubySymbolDelimiter | |
58 | +function! s:run_syntax_fold(args) abort | |
59 | + let [_0, _1, groups, cmd; _] = matchlist(a:args, '\(["'']\)\(.\{-}\)\1\s\+\(.*\)') | |
60 | + if call('s:foldable', split(groups)) | |
61 | + let cmd .= ' fold' | |
62 | + endif | |
63 | + exe cmd | |
64 | +endfunction | |
65 | + | |
66 | +com! -nargs=* SynFold call s:run_syntax_fold(<q-args>) | |
67 | + | |
68 | +" Not-Top Cluster {{{1 | |
69 | +syn cluster rubyNotTop contains=@rubyCommentNotTop,@rubyStringNotTop,@rubyRegexpSpecial,@rubyDeclaration,@rubyExceptionHandler,@rubyClassOperator,rubyConditional,rubyModuleName,rubyClassName,rubySymbolDelimiter,rubyParentheses | |
50 | 70 | |
51 | 71 | " Whitespace Errors {{{1 |
52 | 72 | if exists("ruby_space_errors") |
@@ -59,427 +79,400 @@ | ||
59 | 79 | endif |
60 | 80 | |
61 | 81 | " Operators {{{1 |
62 | -if exists("ruby_operators") | |
63 | - syn match rubyOperator "[~!^|*/%+-]\|&\.\@!\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|=\@1<!>\|\*\*\|\.\.\.\|\.\.\|::" | |
64 | - syn match rubyOperator "->\|-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!=" | |
65 | - syn region rubyBracketOperator matchgroup=rubyOperator start="\%(\w[?!]\=\|[]})]\)\@2<=\[\s*" end="\s*]" contains=ALLBUT,@rubyNotTop | |
82 | + | |
83 | +syn match rubyEnglishBooleanOperator "\<\%(and\|or\|not\)\>" | |
84 | + | |
85 | +if exists("ruby_operators") || exists("ruby_pseudo_operators") | |
86 | + syn match rubyDotOperator "\.\|&\." | |
87 | + | |
88 | + syn match rubyTernaryOperator "\%(\w\|[^\x00-\x7F]\)\@1<!?\|:" | |
89 | + syn match rubyArithmeticOperator "\*\*\|[*/%+]\|->\@!" | |
90 | + syn match rubyComparisonOperator "<=>\|<=\|<\|>=\|[-=]\@1<!>" | |
91 | + syn match rubyBitwiseOperator "[~^|]\|&\.\@!\|<<\|>>" | |
92 | + syn match rubyBooleanOperator "\%(\w\|[^\x00-\x7F]\)\@1<!!\|&&\|||" | |
93 | + syn match rubyRangeOperator "\.\.\.\=" | |
94 | + syn match rubyAssignmentOperator "=>\@!\|-=\|/=\|\*\*=\|\*=\|&&=\|&=\|||=\||=\|%=\|+=\|>>=\|<<=\|\^=" | |
95 | + syn match rubyAssignmentOperator "=>\@!" containedin=rubyBlockParameterList " TODO: this is inelegant | |
96 | + syn match rubyEqualityOperator "===\|==\|!=\|!\~\|=\~" | |
97 | + | |
98 | + syn region rubyBracketOperator matchgroup=rubyOperator start="\%(\%(\w\|[^\x00-\x7F]\)[?!]\=\|[]})]\)\@2<=\[" end="]" contains=ALLBUT,@rubyNotTop | |
99 | + | |
100 | + syn match rubyScopeOperator "::" | |
101 | + syn match rubySuperClassOperator "<" contained | |
102 | + syn match rubyEigenClassOperator "<<" contained | |
103 | + syn match rubyLambdaOperator "->" | |
104 | + syn match rubySplatOperator "\%([[{(|,=]\_s*\)\@<=\*" | |
105 | + syn match rubySplatOperator "\%(^\|\s\)\@1<=\*\%(\h\|[^\x00-\x7F]\|[:$@[]\)\@=" | |
106 | + syn match rubyDoubleSplatOperator "\%([{(|,]\_s*\)\@<=\*\*" | |
107 | + syn match rubyDoubleSplatOperator "\s\@1<=\*\*\%(\h\|[^\x00-\x7F]\|[:$@{]\)\@=" | |
108 | + syn match rubyProcOperator "\%([[(|,]\_s*\)\@<=&" | |
109 | + syn match rubyProcOperator "\s\@1<=&\%(\h\|[^\x00-\x7F]\|[:$@]\|->\)\@=" | |
110 | + | |
111 | + syn cluster rubyProperOperator contains=rubyTernaryOperator,rubyArithmeticOperator,rubyComparisonOperator,rubyBitwiseOperator,rubyBooleanOperator,rubyRangeOperator,rubyAssignmentOperator,rubyEqualityOperator,rubyDefinedOperator,rubyEnglishBooleanOperator | |
112 | + syn cluster rubyClassOperator contains=rubyEigenClassOperator,rubySuperClassOperator | |
113 | + syn cluster rubyPseudoOperator contains=rubyDotOperator,rubyScopeOperator,rubyEigenClassOperator,rubySuperClassOperator,rubyLambdaOperator,rubySplatOperator,rubyDoubleSplatOperator,rubyProcOperator | |
114 | + syn cluster rubyOperator contains=ruby.*Operator | |
66 | 115 | endif |
67 | 116 | |
68 | -" Expression Substitution and Backslash Notation {{{1 | |
69 | -syn match rubyStringEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display | |
70 | -syn match rubyStringEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display | |
71 | -syn match rubyQuoteEscape "\\[\\']" contained display | |
72 | - | |
117 | +" String Interpolation and Backslash Notation {{{1 | |
73 | 118 | syn region rubyInterpolation matchgroup=rubyInterpolationDelimiter start="#{" end="}" contained contains=ALLBUT,@rubyNotTop |
74 | -syn match rubyInterpolation "#\%(\$\|@@\=\)\w\+" display contained contains=rubyInterpolationDelimiter,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable,rubyPredefinedVariable | |
75 | -syn match rubyInterpolationDelimiter "#\ze\%(\$\|@@\=\)\w\+" display contained | |
76 | -syn match rubyInterpolation "#\$\%(-\w\|\W\)" display contained contains=rubyInterpolationDelimiter,rubyPredefinedVariable,rubyInvalidVariable | |
77 | -syn match rubyInterpolationDelimiter "#\ze\$\%(-\w\|\W\)" display contained | |
78 | -syn region rubyNoInterpolation start="\\#{" end="}" contained | |
79 | -syn match rubyNoInterpolation "\\#{" display contained | |
80 | -syn match rubyNoInterpolation "\\#\%(\$\|@@\=\)\w\+" display contained | |
81 | -syn match rubyNoInterpolation "\\#\$\W" display contained | |
119 | +syn match rubyInterpolation "#\$\%(-\w\|[!$&"'*+,./0:;<>?@\`~_]\|\w\+\)" display contained contains=rubyInterpolationDelimiter,@rubyGlobalVariable | |
120 | +syn match rubyInterpolation "#@@\=\w\+" display contained contains=rubyInterpolationDelimiter,rubyInstanceVariable,rubyClassVariable | |
121 | +syn match rubyInterpolationDelimiter "#\ze[$@]" display contained | |
82 | 122 | |
83 | -syn match rubyDelimiterEscape "\\[(<{\[)>}\]]" transparent display contained contains=NONE | |
123 | +syn match rubyStringEscape "\\\_." contained display | |
124 | +syn match rubyStringEscape "\\\o\{1,3}\|\\x\x\{1,2}" contained display | |
125 | +syn match rubyStringEscape "\\u\%(\x\{4}\|{\x\{1,6}\%(\s\+\x\{1,6}\)*}\)" contained display | |
126 | +syn match rubyStringEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=.\)" contained display | |
127 | + | |
128 | +syn match rubyBackslashEscape "\\\\" contained display | |
129 | +syn match rubyQuoteEscape "\\'" contained display | |
130 | +syn match rubySpaceEscape "\\ " contained display | |
131 | + | |
132 | +syn match rubyParenthesisEscape "\\[()]" contained display | |
133 | +syn match rubyCurlyBraceEscape "\\[{}]" contained display | |
134 | +syn match rubyAngleBracketEscape "\\[<>]" contained display | |
135 | +syn match rubySquareBracketEscape "\\[[\]]" contained display | |
84 | 136 | |
85 | 137 | syn region rubyNestedParentheses start="(" skip="\\\\\|\\)" matchgroup=rubyString end=")" transparent contained |
86 | 138 | syn region rubyNestedCurlyBraces start="{" skip="\\\\\|\\}" matchgroup=rubyString end="}" transparent contained |
87 | 139 | syn region rubyNestedAngleBrackets start="<" skip="\\\\\|\\>" matchgroup=rubyString end=">" transparent contained |
88 | 140 | syn region rubyNestedSquareBrackets start="\[" skip="\\\\\|\\\]" matchgroup=rubyString end="\]" transparent contained |
89 | 141 | |
142 | +syn cluster rubySingleCharEscape contains=rubyBackslashEscape,rubyQuoteEscape,rubySpaceEscape,rubyParenthesisEscape,rubyCurlyBraceEscape,rubyAngleBracketEscape,rubySquareBracketEscape | |
143 | +syn cluster rubyNestedBrackets contains=rubyNested.\+ | |
144 | +syn cluster rubyStringSpecial contains=rubyInterpolation,rubyStringEscape | |
145 | +syn cluster rubyStringNotTop contains=@rubyStringSpecial,@rubyNestedBrackets,@rubySingleCharEscape | |
146 | + | |
90 | 147 | " Regular Expression Metacharacters {{{1 |
91 | -" These are mostly Oniguruma ready | |
92 | -syn region rubyRegexpComment matchgroup=rubyRegexpSpecial start="(?#" skip="\\)" end=")" contained | |
93 | -syn region rubyRegexpParens matchgroup=rubyRegexpSpecial start="(\(?:\|?<\=[=!]\|?>\|?<[a-z_]\w*>\|?[imx]*-[imx]*:\=\|\%(?#\)\@!\)" skip="\\)" end=")" contained transparent contains=@rubyRegexpSpecial | |
94 | -syn region rubyRegexpBrackets matchgroup=rubyRegexpCharClass start="\[\^\=" skip="\\\]" end="\]" contained transparent contains=rubyStringEscape,rubyRegexpEscape,rubyRegexpCharClass oneline | |
95 | -syn match rubyRegexpCharClass "\\[DdHhSsWw]" contained display | |
96 | -syn match rubyRegexpCharClass "\[:\^\=\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|xdigit\):\]" contained | |
97 | -syn match rubyRegexpEscape "\\[].*?+^$|\\/(){}[]" contained | |
98 | -syn match rubyRegexpQuantifier "[*?+][?+]\=" contained display | |
99 | -syn match rubyRegexpQuantifier "{\d\+\%(,\d*\)\=}?\=" contained display | |
100 | -syn match rubyRegexpAnchor "[$^]\|\\[ABbGZz]" contained display | |
101 | -syn match rubyRegexpDot "\." contained display | |
102 | -syn match rubyRegexpSpecial "|" contained display | |
103 | -syn match rubyRegexpSpecial "\\[1-9]\d\=\d\@!" contained display | |
104 | -syn match rubyRegexpSpecial "\\k<\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\=>" contained display | |
105 | -syn match rubyRegexpSpecial "\\k'\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\='" contained display | |
106 | -syn match rubyRegexpSpecial "\\g<\%([a-z_]\w*\|-\=\d\+\)>" contained display | |
107 | -syn match rubyRegexpSpecial "\\g'\%([a-z_]\w*\|-\=\d\+\)'" contained display | |
148 | +syn region rubyRegexpComment matchgroup=rubyRegexpSpecial start="(?#" skip="\\\\\|\\)" end=")" contained | |
149 | +syn region rubyRegexpParens matchgroup=rubyRegexpSpecial start="(\(?:\|?<\=[=!]\|?>\|?<[a-z_]\w*>\|?[imx]*-[imx]*:\=\|\%(?#\)\@!\)" skip="\\\\\|\\)" end=")" contained transparent contains=@rubyRegexpSpecial | |
150 | +syn region rubyRegexpBrackets matchgroup=rubyRegexpCharClass start="\[\^\=" skip="\\\\\|\\\]" end="\]" contained transparent contains=rubyRegexpBrackets,rubyStringEscape,rubyRegexpEscape,rubyRegexpCharClass,rubyRegexpIntersection oneline | |
151 | +syn match rubyRegexpCharClass "\\[DdHhRSsWw]" contained display | |
152 | +syn match rubyRegexpCharClass "\[:\^\=\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|word\|xdigit\):\]" contained | |
153 | +syn match rubyRegexpCharClass "\\[pP]{^\=.\{-}}" contained display | |
154 | +syn match rubyRegexpEscape "\\[].*?+^$|\\/(){}[]" contained " see commit e477f10 | |
155 | +syn match rubyRegexpQuantifier "[*?+][?+]\=" contained display | |
156 | +syn match rubyRegexpQuantifier "{\d\+\%(,\d*\)\=}?\=" contained display | |
157 | +syn match rubyRegexpAnchor "[$^]\|\\[ABbGZz]" contained display | |
158 | +syn match rubyRegexpDot "\.\|\\X" contained display | |
159 | +syn match rubyRegexpIntersection "&&" contained display | |
160 | +syn match rubyRegexpSpecial "\\K" contained display | |
161 | +syn match rubyRegexpSpecial "|" contained display | |
162 | +syn match rubyRegexpSpecial "\\[1-9]\d\=\d\@!" contained display | |
163 | +syn match rubyRegexpSpecial "\\k<\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\=>" contained display | |
164 | +syn match rubyRegexpSpecial "\\k'\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\='" contained display | |
165 | +syn match rubyRegexpSpecial "\\g<\%([a-z_]\w*\|-\=\d\+\)>" contained display | |
166 | +syn match rubyRegexpSpecial "\\g'\%([a-z_]\w*\|-\=\d\+\)'" contained display | |
108 | 167 | |
109 | -syn cluster rubyStringSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyStringEscape | |
110 | -syn cluster rubyExtendedStringSpecial contains=@rubyStringSpecial,rubyNestedParentheses,rubyNestedCurlyBraces,rubyNestedAngleBrackets,rubyNestedSquareBrackets | |
111 | -syn cluster rubyRegexpSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyStringEscape,rubyRegexpSpecial,rubyRegexpEscape,rubyRegexpBrackets,rubyRegexpCharClass,rubyRegexpDot,rubyRegexpQuantifier,rubyRegexpAnchor,rubyRegexpParens,rubyRegexpComment | |
168 | +syn cluster rubyRegexpSpecial contains=@rubyStringSpecial,rubyRegexpSpecial,rubyRegexpEscape,rubyRegexpBrackets,rubyRegexpCharClass,rubyRegexpDot,rubyRegexpQuantifier,rubyRegexpAnchor,rubyRegexpParens,rubyRegexpComment,rubyRegexpIntersection | |
112 | 169 | |
113 | -" Numbers and ASCII Codes {{{1 | |
114 | -syn match rubyASCIICode "\%(\w\|[]})\"'/]\)\@1<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)\)" | |
115 | -syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[xX]\x\+\%(_\x\+\)*r\=i\=\>" display | |
116 | -syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0[dD]\)\=\%(0\|[1-9]\d*\%(_\d\+\)*\)r\=i\=\>" display | |
117 | -syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[oO]\=\o\+\%(_\o\+\)*r\=i\=\>" display | |
118 | -syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[bB][01]\+\%(_[01]\+\)*r\=i\=\>" display | |
119 | -syn match rubyFloat "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\.\d\+\%(_\d\+\)*r\=i\=\>" display | |
120 | -syn match rubyFloat "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\%(\.\d\+\%(_\d\+\)*\)\=\%([eE][-+]\=\d\+\%(_\d\+\)*\)r\=i\=\>" display | |
170 | +" Numbers {{{1 | |
171 | +syn match rubyInteger "\%(\%(\w\|[^\x00-\x7F]\|[]})\"']\s*\)\@<!-\)\=\<0[xX]\x\+\%(_\x\+\)*r\=i\=\>" display | |
172 | +syn match rubyInteger "\%(\%(\w\|[^\x00-\x7F]\|[]})\"']\s*\)\@<!-\)\=\<\%(0[dD]\)\=\%(0\|[1-9]\d*\%(_\d\+\)*\)r\=i\=\>" display | |
173 | +syn match rubyInteger "\%(\%(\w\|[^\x00-\x7F]\|[]})\"']\s*\)\@<!-\)\=\<0[oO]\=\o\+\%(_\o\+\)*r\=i\=\>" display | |
174 | +syn match rubyInteger "\%(\%(\w\|[^\x00-\x7F]\|[]})\"']\s*\)\@<!-\)\=\<0[bB][01]\+\%(_[01]\+\)*r\=i\=\>" display | |
175 | +syn match rubyFloat "\%(\%(\w\|[^\x00-\x7F]\|[]})\"']\s*\)\@<!-\)\=\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\.\d\+\%(_\d\+\)*r\=i\=\>" display | |
176 | +syn match rubyFloat "\%(\%(\w\|[^\x00-\x7F]\|[]})\"']\s*\)\@<!-\)\=\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\%(\.\d\+\%(_\d\+\)*\)\=\%([eE][-+]\=\d\+\%(_\d\+\)*\)i\=\>" display | |
121 | 177 | |
122 | 178 | " Identifiers {{{1 |
123 | -syn match rubyLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent | |
124 | -syn match rubyBlockArgument "&[_[:lower:]][_[:alnum:]]" contains=NONE display transparent | |
125 | - | |
126 | -syn match rubyClassName "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@!" contained | |
127 | -syn match rubyModuleName "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@!" contained | |
128 | -syn match rubyConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@!" | |
129 | -syn match rubyClassVariable "@@\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" display | |
130 | -syn match rubyInstanceVariable "@\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" display | |
131 | -syn match rubyGlobalVariable "$\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\|-.\)" | |
132 | -syn match rubySymbolDelimiter ":" contained | |
133 | -syn match rubySymbol "[]})\"':]\@1<!:\%(\^\|\~@\|\~\|<<\|<=>\|<=\|<\|===\|[=!]=\|[=!]\~\|!@\|!\|>>\|>=\|>\||\|-@\|-\|/\|\[]=\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)" contains=rubySymbolDelimiter | |
134 | -syn match rubySymbol "[]})\"':]\@1<!:\$\%(-.\|[`~<=>_,;:!?/.'"@$*\&+0]\)" contains=rubySymbolDelimiter | |
135 | -syn match rubySymbol "[]})\"':]\@1<!:\%(\$\|@@\=\)\=\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" contains=rubySymbolDelimiter | |
136 | -syn match rubySymbol "[]})\"':]\@1<!:\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\%([?!=]>\@!\)\=" contains=rubySymbolDelimiter | |
137 | - | |
138 | -if s:foldable(':') | |
139 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="[]})\"':]\@1<!:'" end="'" skip="\\\\\|\\'" contains=rubyQuoteEscape fold | |
140 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="[]})\"':]\@1<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold | |
141 | -else | |
142 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="[]})\"':]\@1<!:'" end="'" skip="\\\\\|\\'" contains=rubyQuoteEscape | |
143 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="[]})\"':]\@1<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial | |
144 | -endif | |
145 | - | |
146 | -syn match rubyCapitalizedMethod "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)*\s*(\@=" | |
147 | - | |
148 | -syn match rubyBlockParameter "\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" contained | |
149 | -syn region rubyBlockParameterList start="\%(\%(\<do\>\|{\)\_s*\)\@32<=|" end="|" oneline display contains=rubyBlockParameter | |
150 | - | |
151 | -syn match rubyInvalidVariable "$[^ A-Za-z_-]" | |
152 | -syn match rubyPredefinedVariable #$[!$&"'*+,./0:;<=>?@\`~]# | |
153 | -syn match rubyPredefinedVariable "$\d\+" display | |
154 | -syn match rubyPredefinedVariable "$_\>" display | |
155 | -syn match rubyPredefinedVariable "$-[0FIKadilpvw]\>" display | |
156 | -syn match rubyPredefinedVariable "$\%(deferr\|defout\|stderr\|stdin\|stdout\)\>" display | |
157 | -syn match rubyPredefinedVariable "$\%(DEBUG\|FILENAME\|KCODE\|LOADED_FEATURES\|LOAD_PATH\|PROGRAM_NAME\|SAFE\|VERBOSE\)\>" display | |
158 | -syn match rubyPredefinedConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\%(ARGF\|ARGV\|ENV\|DATA\|FALSE\|NIL\|STDERR\|STDIN\|STDOUT\|TOPLEVEL_BINDING\|TRUE\)\>\%(\s*(\)\@!" | |
159 | -syn match rubyPredefinedConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\%(RUBY_\%(VERSION\|RELEASE_DATE\|PLATFORM\|PATCHLEVEL\|REVISION\|DESCRIPTION\|COPYRIGHT\|ENGINE\)\)\>\%(\s*(\)\@!" | |
179 | +syn match rubyClassName "\%(\%(^\|[^.]\)\.\s*\)\@<!\<[[:upper:]]\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@!" contained | |
180 | +syn match rubyModuleName "\%(\%(^\|[^.]\)\.\s*\)\@<!\<[[:upper:]]\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@!" contained | |
181 | +syn match rubyConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<[[:upper:]]\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@!" | |
182 | +syn match rubyClassVariable "@@\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" display | |
183 | +syn match rubyInstanceVariable "@\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" display | |
184 | +syn match rubyGlobalVariable "$\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\|-.\)" | |
185 | +syn match rubySymbolDelimiter ":" contained | |
186 | +syn match rubySymbol "[]})\"':]\@1<!:\%(\^\|\~@\|\~\|<<\|<=>\|<=\|<\|===\|[=!]=\|[=!]\~\|!@\|!\|>>\|>=\|>\||\|-@\|-\|/\|\[]=\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)" contains=rubySymbolDelimiter | |
187 | +syn match rubySymbol "[]})\"':]\@1<!:\$\%(-.\|[`~<=>_,;:!?/.'"@$*\&+0]\)" contains=rubySymbolDelimiter | |
188 | +syn match rubySymbol "[]})\"':]\@1<!:\%(\$\|@@\=\)\=\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" contains=rubySymbolDelimiter | |
189 | +syn match rubySymbol "[]})\"':]\@1<!:\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\%([?!=]>\@!\)\=" contains=rubySymbolDelimiter | |
160 | 190 | |
161 | -" Normal Regular Expression {{{1 | |
162 | -if s:foldable('/') | |
163 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,{[<>?:*+-]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold | |
164 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/\%([ \t=]\|$\)\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold | |
165 | -else | |
166 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,{[<>?:*+-]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial | |
167 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/\%([ \t=]\|$\)\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial | |
168 | -endif | |
191 | +SynFold ':' syn region rubySymbol matchgroup=rubySymbolDelimiter start="[]})\"':]\@1<!:'" end="'" skip="\\\\\|\\'" contains=rubyQuoteEscape,rubyBackslashEscape | |
192 | +SynFold ':' syn region rubySymbol matchgroup=rubySymbolDelimiter start="[]})\"':]\@1<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial | |
169 | 193 | |
170 | -" Generalized Regular Expression {{{1 | |
171 | -if s:foldable('%') | |
172 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial fold | |
173 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyRegexpSpecial fold | |
174 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyRegexpSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape fold | |
175 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyRegexpSpecial fold | |
176 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyRegexpSpecial fold | |
177 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z(\s\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial fold | |
178 | -else | |
179 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial | |
180 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyRegexpSpecial | |
181 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyRegexpSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape | |
182 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyRegexpSpecial | |
183 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyRegexpSpecial | |
184 | - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z(\s\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial | |
185 | -endif | |
194 | +syn match rubyCapitalizedMethod "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@=" | |
186 | 195 | |
187 | -" Normal String {{{1 | |
188 | -let s:spell_cluster = exists('ruby_spellcheck_strings') ? ',@Spell' : '' | |
189 | -exe 'syn region rubyString matchgroup=rubyStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" ' . | |
190 | - \ (s:foldable('%') ? 'fold' : '') . ' contains=@rubyStringSpecial' . s:spell_cluster | |
191 | -exe 'syn region rubyString matchgroup=rubyStringDelimiter start="''" end="''" skip="\\\\\|\\''" ' . | |
192 | - \ (s:foldable('%') ? 'fold' : '') . ' contains=rubyQuoteEscape' . s:spell_cluster | |
196 | +syn region rubyParentheses start="(" end=")" contains=ALLBUT,@rubyNotTop containedin=rubyBlockParameterList | |
197 | +syn region rubyBlockParameterList start="\%(\%(\<do\>\|{\)\_s*\)\@32<=|" end="|" contains=ALLBUT,@rubyNotTop,@rubyProperOperator | |
193 | 198 | |
194 | -" Shell Command Output {{{1 | |
195 | -if s:foldable('%') | |
196 | - syn region rubyString matchgroup=rubyStringDelimiter start="`" end="`" skip="\\\\\|\\`" contains=@rubyStringSpecial fold | |
197 | -else | |
198 | - syn region rubyString matchgroup=rubyStringDelimiter start="`" end="`" skip="\\\\\|\\`" contains=@rubyStringSpecial | |
199 | +if exists('ruby_global_variable_error') | |
200 | + syn match rubyGlobalVariableError "$[^A-Za-z_]" display | |
201 | + syn match rubyGlobalVariableError "$-[^0FIKWadilpvw]" display | |
199 | 202 | endif |
200 | 203 | |
201 | -" Generalized Single Quoted String, Symbol and Array of Strings {{{1 | |
202 | -if s:foldable('%') | |
203 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold | |
204 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimiterEscape | |
205 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimiterEscape | |
206 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimiterEscape | |
207 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw](" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimiterEscape | |
208 | - syn region rubyString matchgroup=rubyStringDelimiter start="%q\z(\s\)" end="\z1" skip="\\\\\|\\\z1" fold | |
209 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold | |
210 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimiterEscape | |
211 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimiterEscape | |
212 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimiterEscape | |
213 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s(" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimiterEscape | |
214 | - syn region rubyString matchgroup=rubyStringDelimiter start="%s\z(\s\)" end="\z1" skip="\\\\\|\\\z1" fold | |
215 | -else | |
216 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" | |
217 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]{" end="}" skip="\\\\\|\\}" contains=rubyNestedCurlyBraces,rubyDelimiterEscape | |
218 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]<" end=">" skip="\\\\\|\\>" contains=rubyNestedAngleBrackets,rubyDelimiterEscape | |
219 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\[" end="\]" skip="\\\\\|\\\]" contains=rubyNestedSquareBrackets,rubyDelimiterEscape | |
220 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw](" end=")" skip="\\\\\|\\)" contains=rubyNestedParentheses,rubyDelimiterEscape | |
221 | - syn region rubyString matchgroup=rubyStringDelimiter start="%q\z(\s\)" end="\z1" skip="\\\\\|\\\z1" | |
222 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" | |
223 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s{" end="}" skip="\\\\\|\\}" contains=rubyNestedCurlyBraces,rubyDelimiterEscape | |
224 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s<" end=">" skip="\\\\\|\\>" contains=rubyNestedAngleBrackets,rubyDelimiterEscape | |
225 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\[" end="\]" skip="\\\\\|\\\]" contains=rubyNestedSquareBrackets,rubyDelimiterEscape | |
226 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s(" end=")" skip="\\\\\|\\)" contains=rubyNestedParentheses,rubyDelimiterEscape | |
227 | - syn region rubyString matchgroup=rubyStringDelimiter start="%s\z(\s\)" end="\z1" skip="\\\\\|\\\z1" | |
228 | -endif | |
229 | - | |
230 | -" Generalized Double Quoted String and Array of Strings and Shell Command Output {{{1 | |
231 | -" Note: %= is not matched here as the beginning of a double quoted string | |
232 | -if s:foldable('%') | |
233 | - syn region rubyString matchgroup=rubyStringDelimiter start="%\z([~`!@#$%^&*_\-+|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold | |
234 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold | |
235 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\={" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimiterEscape fold | |
236 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape fold | |
237 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape fold | |
238 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape fold | |
239 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[Qx]\z(\s\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold | |
240 | -else | |
241 | - syn region rubyString matchgroup=rubyStringDelimiter start="%\z([~`!@#$%^&*_\-+|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial | |
242 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial | |
243 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\={" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimiterEscape | |
244 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape | |
245 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape | |
246 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape | |
247 | - syn region rubyString matchgroup=rubyStringDelimiter start="%[Qx]\z(\s\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial | |
248 | -endif | |
204 | +syn match rubyPredefinedVariable #$[!$&"'*+,./0:;<>?@\`~]# | |
205 | +syn match rubyPredefinedVariable "$\d\+" display | |
206 | +syn match rubyPredefinedVariable "$_\>" display | |
207 | +syn match rubyPredefinedVariable "$-[0FIWadilpvw]\>" display | |
208 | +syn match rubyPredefinedVariable "$\%(stderr\|stdin\|stdout\)\>" display | |
209 | +syn match rubyPredefinedVariable "$\%(DEBUG\|FILENAME\|LOADED_FEATURES\|LOAD_PATH\|PROGRAM_NAME\|SAFE\|VERBOSE\)\>" display | |
210 | +syn match rubyPredefinedConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\%(ARGF\|ARGV\|ENV\|DATA\|STDERR\|STDIN\|STDOUT\|TOPLEVEL_BINDING\)\>\%(\s*(\)\@!" | |
211 | +syn match rubyPredefinedConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\%(RUBY_\%(VERSION\|RELEASE_DATE\|PLATFORM\|PATCHLEVEL\|REVISION\|DESCRIPTION\|COPYRIGHT\|ENGINE\)\)\>\%(\s*(\)\@!" | |
249 | 212 | |
250 | -" Array of Symbols {{{1 | |
251 | -if s:foldable('%') | |
252 | - " Array of Symbols | |
253 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold | |
254 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimiterEscape | |
255 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimiterEscape | |
256 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimiterEscape | |
257 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i(" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimiterEscape | |
258 | - | |
259 | - " Array of interpolated Symbols | |
260 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold | |
261 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I{" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimiterEscape fold | |
262 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape fold | |
263 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape fold | |
264 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape fold | |
265 | -else | |
266 | - " Array of Symbols | |
267 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" | |
268 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i{" end="}" skip="\\\\\|\\}" contains=rubyNestedCurlyBraces,rubyDelimiterEscape | |
269 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i<" end=">" skip="\\\\\|\\>" contains=rubyNestedAngleBrackets,rubyDelimiterEscape | |
270 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\[" end="\]" skip="\\\\\|\\\]" contains=rubyNestedSquareBrackets,rubyDelimiterEscape | |
271 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i(" end=")" skip="\\\\\|\\)" contains=rubyNestedParentheses,rubyDelimiterEscape | |
272 | - | |
273 | - " Array of interpolated Symbols | |
274 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial | |
275 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I{" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimiterEscape | |
276 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape | |
277 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape | |
278 | - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape | |
279 | -endif | |
213 | +" Deprecated/removed in 1.9 | |
214 | +syn match rubyPredefinedVariable "$=" | |
215 | +syn match rubyPredefinedVariable "$-K\>" display | |
216 | +syn match rubyPredefinedVariable "$\%(deferr\|defout\)\>" display | |
217 | +syn match rubyPredefinedVariable "$KCODE\>" display | |
218 | +" Deprecated/removed in 2.4 | |
219 | +syn match rubyPredefinedConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\%(FALSE\|NIL\|TRUE\)\>\%(\s*(\)\@!" | |
280 | 220 | |
281 | -" Here Document {{{1 | |
282 | -syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<[-~]\=\zs\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)+ end=+$+ oneline contains=ALLBUT,@rubyNotTop | |
283 | -syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<[-~]\=\zs"\%([^"]*\)"+ end=+$+ oneline contains=ALLBUT,@rubyNotTop | |
284 | -syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<[-~]\=\zs'\%([^']*\)'+ end=+$+ oneline contains=ALLBUT,@rubyNotTop | |
285 | -syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<[-~]\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=ALLBUT,@rubyNotTop | |
286 | - | |
287 | -if s:foldable('<<') | |
288 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend | |
289 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend | |
290 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc fold keepend | |
291 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend | |
221 | +syn cluster rubyGlobalVariable contains=rubyGlobalVariable,rubyPredefinedVariable,rubyGlobalVariableError | |
292 | 222 | |
293 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend | |
294 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend | |
295 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart fold keepend | |
296 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend | |
297 | -else | |
298 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial keepend | |
299 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial keepend | |
300 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc keepend | |
301 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial keepend | |
223 | +" Normal Regular Expressions {{{1 | |
224 | +SynFold '/' syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,{[<>?:*+-]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial nextgroup=@rubyModifier skipwhite | |
225 | +SynFold '/' syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\s\+\)\@<=/\%(=\|\_s\)\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial nextgroup=@rubyModifier skipwhite | |
302 | 226 | |
303 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial keepend | |
304 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial keepend | |
305 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart keepend | |
306 | - syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial keepend | |
307 | -endif | |
227 | +" Generalized Regular Expressions {{{1 | |
228 | +SynFold '%' syn region rubyRegexp matchgroup=rubyPercentRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial nextgroup=@rubyModifier skipwhite | |
229 | +SynFold '%' syn region rubyRegexp matchgroup=rubyPercentRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyRegexpSpecial | |
230 | +SynFold '%' syn region rubyRegexp matchgroup=rubyPercentRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyRegexpSpecial,rubyNestedAngleBrackets | |
231 | +SynFold '%' syn region rubyRegexp matchgroup=rubyPercentRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyRegexpSpecial | |
232 | +SynFold '%' syn region rubyRegexp matchgroup=rubyPercentRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyRegexpSpecial | |
233 | +SynFold '%' syn region rubyRegexp matchgroup=rubyPercentRegexpDelimiter start="%r\z(\s\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial | |
308 | 234 | |
309 | -" eRuby Config {{{1 | |
310 | -if exists('main_syntax') && main_syntax == 'eruby' | |
311 | - let b:ruby_no_expensive = 1 | |
312 | -endif | |
235 | +" Characters {{{1 | |
236 | +syn match rubyCharacter "\%(\w\|[^\x00-\x7F]\|[]})\"'/]\)\@1<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\[[:space:]]\|\\\=[^[:space:]]\)\)" | |
237 | +syn match rubyCharacter "\%(\w\|[^\x00-\x7F]\|[]})\"'/]\)\@1<!?\\u\%(\x\{4}\|{\x\{1,6}}\)" | |
238 | + | |
239 | +" Normal Strings {{{1 | |
240 | +let s:spell_cluster = exists('ruby_spellcheck_strings') ? ',@Spell' : '' | |
241 | +let s:fold_arg = s:foldable('string') ? ' fold' : '' | |
242 | +exe 'syn region rubyString matchgroup=rubyStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial' . s:spell_cluster . s:fold_arg | |
243 | +exe 'syn region rubyString matchgroup=rubyStringDelimiter start="''" end="''" skip="\\\\\|\\''" contains=rubyQuoteEscape,rubyBackslashEscape' . s:spell_cluster . s:fold_arg | |
244 | +unlet s:spell_cluster s:fold_arg | |
245 | + | |
246 | +" Shell Command Output {{{1 | |
247 | +SynFold 'string' syn region rubyString matchgroup=rubyStringDelimiter start="`" end="`" skip="\\\\\|\\`" contains=@rubyStringSpecial | |
248 | + | |
249 | +" Generalized Single Quoted Strings, Symbols, Array of Strings and Array of Symbols {{{1 | |
250 | + | |
251 | +" Non-bracket punctuation delimiters {{{2 | |
252 | +let s:names = { '~': 'Tilde', '`': 'BackQuote', '!': 'Bang', '@': 'At', '#': 'Hash', '$': 'Dollar', '%': 'Percent', '^': 'Caret', | |
253 | + \ '&': 'Ampersand', '*': 'Asterix', '_': 'Underscore', '-': 'Dash', '+': 'Plus', '=': 'Equals', '|': 'Bar', | |
254 | + \ '\': 'Backslash', ':': 'Colon', ';': 'Semicolon', '"': 'DoubleQuote', "'": 'Quote', ',': 'Comma', '.': 'Period', | |
255 | + \ '?': 'QuestionMark', '/': 'ForwardSlash' } | |
256 | + | |
257 | +for s:delimiter in keys(s:names) | |
258 | + let s:group = 'ruby' . s:names[s:delimiter] . 'Escape' | |
259 | + | |
260 | + if s:delimiter =~ '[\"]' | |
261 | + let s:delimiter = '\' . s:delimiter | |
262 | + endif | |
263 | + | |
264 | + exe 'syn match ' . s:group . ' "\V\\' . s:delimiter . '" contained display' | |
265 | + exe 'syn cluster rubySingleCharEscape add=' . s:group | |
266 | + exe 'SynFold ''%'' syn region rubyString matchgroup=rubyPercentStringDelimiter start="\V%q' . s:delimiter . '" end="\V' . s:delimiter . '" skip="\V\\\\\|\\' . s:delimiter . '" contains=rubyBackslashEscape,' . s:group . ' nextgroup=@rubyModifier skipwhite' | |
267 | + exe 'SynFold ''%'' syn region rubyString matchgroup=rubyPercentStringDelimiter start="\V%w' . s:delimiter . '" end="\V' . s:delimiter . '" skip="\V\\\\\|\\' . s:delimiter . '" contains=rubyBackslashEscape,rubySpaceEscape,' . s:group . ' nextgroup=@rubyModifier skipwhite' | |
268 | + exe 'SynFold ''%'' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="\V%s' . s:delimiter . '" end="\V' . s:delimiter . '" skip="\V\\\\\|\\' . s:delimiter . '" contains=rubyBackslashEscape,' . s:group . ' nextgroup=@rubyModifier skipwhite' | |
269 | + exe 'SynFold ''%'' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="\V%i' . s:delimiter . '" end="\V' . s:delimiter . '" skip="\V\\\\\|\\' . s:delimiter . '" contains=rubyBackslashEscape,rubySpaceEscape,' . s:group . ' nextgroup=@rubyModifier skipwhite' | |
270 | + exe 'hi def link ' . s:group . ' rubyStringEscape' | |
271 | +endfor | |
272 | + | |
273 | +unlet s:delimiter s:group s:names | |
274 | +" }}}2 | |
275 | + | |
276 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%q{" end="}" skip="\\\\\|\\}" contains=rubyBackslashEscape,rubyCurlyBraceEscape,rubyNestedCurlyBraces | |
277 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%q<" end=">" skip="\\\\\|\\>" contains=rubyBackslashEscape,rubyAngleBracketEscape,rubyNestedAngleBrackets | |
278 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%q\[" end="\]" skip="\\\\\|\\\]" contains=rubyBackslashEscape,rubySquareBracketEscape,rubyNestedSquareBrackets | |
279 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%q(" end=")" skip="\\\\\|\\)" contains=rubyBackslashEscape,rubyParenthesisEscape,rubyNestedParentheses | |
280 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%q\z(\s\)" end="\z1" skip="\\\\\|\\\z1" contains=rubyBackslashEscape,rubySpaceEscape | |
281 | + | |
282 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%w{" end="}" skip="\\\\\|\\}" contains=rubyBackslashEscape,rubySpaceEscape,rubyCurlyBraceEscape,rubyNestedCurlyBraces | |
283 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%w<" end=">" skip="\\\\\|\\>" contains=rubyBackslashEscape,rubySpaceEscape,rubyAngleBracketEscape,rubyNestedAngleBrackets | |
284 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%w\[" end="\]" skip="\\\\\|\\\]" contains=rubyBackslashEscape,rubySpaceEscape,rubySquareBracketEscape,rubyNestedSquareBrackets | |
285 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%w(" end=")" skip="\\\\\|\\)" contains=rubyBackslashEscape,rubySpaceEscape,rubyParenthesisEscape,rubyNestedParentheses | |
286 | + | |
287 | +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%s{" end="}" skip="\\\\\|\\}" contains=rubyBackslashEscape,rubyCurlyBraceEscape,rubyNestedCurlyBraces | |
288 | +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%s<" end=">" skip="\\\\\|\\>" contains=rubyBackslashEscape,rubyAngleBracketEscape,rubyNestedAngleBrackets | |
289 | +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%s\[" end="\]" skip="\\\\\|\\\]" contains=rubyBackslashEscape,rubySquareBracketEscape,rubyNestedSquareBrackets | |
290 | +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%s(" end=")" skip="\\\\\|\\)" contains=rubyBackslashEscape,rubyParenthesisEscape,rubyNestedParentheses | |
291 | +SynFold '%' syn region rubyString matchgroup=rubyPercentSymbolDelimiter start="%s\z(\s\)" end="\z1" skip="\\\\\|\\\z1" contains=rubyBackslashEscape,rubySpaceEscape | |
292 | + | |
293 | +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%i{" end="}" skip="\\\\\|\\}" contains=rubyBackslashEscape,rubySpaceEscape,rubyCurlyBraceEscape,rubyNestedCurlyBraces | |
294 | +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%i<" end=">" skip="\\\\\|\\>" contains=rubyBackslashEscape,rubySpaceEscape,rubyAngleBracketEscape,rubyNestedAngleBrackets | |
295 | +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%i\[" end="\]" skip="\\\\\|\\\]" contains=rubyBackslashEscape,rubySpaceEscape,rubySquareBracketEscape,rubyNestedSquareBrackets | |
296 | +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%i(" end=")" skip="\\\\\|\\)" contains=rubyBackslashEscape,rubySpaceEscape,rubyParenthesisEscape,rubyNestedParentheses | |
297 | + | |
298 | +" Generalized Double Quoted Strings, Array of Strings, Array of Symbols and Shell Command Output {{{1 | |
299 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="\%(\%(\w\|[^\x00-\x7F]\|]\)\s*\)\@<!%=" end="=" skip="\\\\\|\\=" contains=@rubyStringSpecial nextgroup=@rubyModifier skipwhite | |
300 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%\z([~`!@#$%^&*_\-+|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial nextgroup=@rubyModifier skipwhite | |
301 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%[QWx]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial nextgroup=@rubyModifier skipwhite | |
302 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%[QWx]\={" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces | |
303 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%[QWx]\=<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets | |
304 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%[QWx]\=\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets | |
305 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%[QWx]\=(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses | |
306 | +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%[Qx]\z(\s\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial | |
307 | + | |
308 | +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%I\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial nextgroup=@rubyModifier skipwhite | |
309 | +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%I{" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces | |
310 | +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%I<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets | |
311 | +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%I\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets | |
312 | +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%I(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses | |
313 | + | |
314 | +" Here Documents {{{1 | |
315 | +syn region rubyHeredocStart matchgroup=rubyHeredocDelimiter start=+\%(\%(class\|::\|\.\@1<!\.\)\_s*\|\%([]})"'`]\)\s\|\w\)\@<!<<[-~]\=\zs\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)+ end=+$+ oneline contains=ALLBUT,@rubyNotTop | |
316 | + | |
317 | +syn region rubyHeredocStart matchgroup=rubyHeredocDelimiter start=+\%(\%(class\|::\|\.\@1<!\.\)\_s*\|\%([]})"'`]\)\s\|\w\)\@<!<<[-~]\=\zs"\%([^"]*\)"+ end=+$+ oneline contains=ALLBUT,@rubyNotTop | |
318 | +syn region rubyHeredocStart matchgroup=rubyHeredocDelimiter start=+\%(\%(class\|::\|\.\@1<!\.\)\_s*\|\%([]})"'`]\)\s\|\w\)\@<!<<[-~]\=\zs'\%([^']*\)'+ end=+$+ oneline contains=ALLBUT,@rubyNotTop | |
319 | +syn region rubyHeredocStart matchgroup=rubyHeredocDelimiter start=+\%(\%(class\|::\|\.\@1<!\.\)\_s*\|\%([]})"'`]\)\s\|\w\)\@<!<<[-~]\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=ALLBUT,@rubyNotTop | |
320 | + | |
321 | +SynFold '<<' syn region rubyString start=+\%(\%(class\|::\|\.\@1<!\.\)\_s*\|\%([]})"'`]\)\s\|\w\)\@<!<<\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyHeredocDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial keepend | |
322 | +SynFold '<<' syn region rubyString start=+\%(\%(class\|::\|\.\@1<!\.\)\_s*\|\%([]})"'`]\)\s\|\w\)\@<!<<"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyHeredocDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial keepend | |
323 | +SynFold '<<' syn region rubyString start=+\%(\%(class\|::\|\.\@1<!\.\)\_s*\|\%([]})"'`]\)\s\|\w\)\@<!<<'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyHeredocDelimiter end=+^\z1$+ contains=rubyHeredocStart keepend | |
324 | +SynFold '<<' syn region rubyString start=+\%(\%(class\|::\|\.\@1<!\.\)\_s*\|\%([]})"'`]\)\s\|\w\)\@<!<<`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyHeredocDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial keepend | |
325 | + | |
326 | +SynFold '<<' syn region rubyString start=+\%(\%(class\|::\|\.\@1<!\.\)\_s*\|\%([]})]\)\s\|\w\)\@<!<<[-~]\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyHeredocDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial keepend | |
327 | +SynFold '<<' syn region rubyString start=+\%(\%(class\|::\|\.\@1<!\.\)\_s*\|\%([]})]\)\s\|\w\)\@<!<<[-~]"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyHeredocDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial keepend | |
328 | +SynFold '<<' syn region rubyString start=+\%(\%(class\|::\|\.\@1<!\.\)\_s*\|\%([]})]\)\s\|\w\)\@<!<<[-~]'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyHeredocDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart keepend | |
329 | +SynFold '<<' syn region rubyString start=+\%(\%(class\|::\|\.\@1<!\.\)\_s*\|\%([]})]\)\s\|\w\)\@<!<<[-~]`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyHeredocDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial keepend | |
313 | 330 | |
314 | 331 | " Module, Class, Method and Alias Declarations {{{1 |
315 | -syn match rubyAliasDeclaration "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable nextgroup=rubyAliasDeclaration2 skipwhite | |
316 | -syn match rubyAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable | |
317 | -syn match rubyMethodDeclaration "[^[:space:];#(]\+" contained contains=rubyConstant,rubyBoolean,rubyPseudoVariable,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable | |
318 | -syn match rubyClassDeclaration "[^[:space:];#<]\+" contained contains=rubyClassName,rubyOperator | |
319 | -syn match rubyModuleDeclaration "[^[:space:];#<]\+" contained contains=rubyModuleName,rubyOperator | |
320 | -syn match rubyMethodName "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:]_.:?!=]\@!" contained containedin=rubyMethodDeclaration | |
321 | -syn match rubyMethodName "\%(\s\|^\)\@1<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2 | |
322 | -syn match rubyMethodName "\%([[:space:].]\|^\)\@2<=\%(\[\]=\=\|\*\*\|[-+!~]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration | |
332 | +syn match rubyAliasDeclaration "[^[:space:];#.()]\+" contained contains=rubySymbol,@rubyGlobalVariable nextgroup=rubyAliasDeclaration2 skipwhite | |
333 | +syn match rubyAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=rubySymbol,@rubyGlobalVariable | |
334 | +syn match rubyMethodDeclaration "[^[:space:];#(]\+" contained contains=rubyConstant,rubyBoolean,rubyPseudoVariable,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable | |
335 | +syn match rubyClassDeclaration "[^[:space:];#<]\+" contained contains=rubyClassName,rubyScopeOperator nextgroup=rubySuperClassOperator skipwhite skipnl | |
336 | +syn match rubyModuleDeclaration "[^[:space:];#<]\+" contained contains=rubyModuleName,rubyScopeOperator | |
323 | 337 | |
324 | -syn cluster rubyDeclaration contains=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration,rubyModuleDeclaration,rubyClassDeclaration,rubyMethodName,rubyBlockParameter | |
338 | +syn match rubyMethodName "\<\%([_[:alpha:]]\|[^\x00-\x7F]\)\%([_[:alnum:]]\|[^\x00-\x7F]\)*[?!=]\=\%([[:alnum:]_.:?!=]\|[^\x00-\x7F]\)\@!" contained containedin=rubyMethodDeclaration | |
339 | +syn match rubyMethodName "\%(\s\|^\)\@1<=\%([_[:alpha:]]\|[^\x00-\x7F]\)\%([_[:alnum:]]\|[^\x00-\x7F]\)*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2 | |
340 | +syn match rubyMethodName "\%([[:space:].]\|^\)\@1<=\%(\[\]=\=\|\*\*\|[-+!~]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration | |
341 | + | |
342 | +syn cluster rubyDeclaration contains=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration,rubyModuleDeclaration,rubyClassDeclaration,rubyMethodName | |
325 | 343 | |
326 | 344 | " Keywords {{{1 |
327 | -" Note: the following keywords have already been defined: | |
328 | -" begin case class def do end for if module unless until while | |
329 | -syn match rubyControl "\<\%(and\|break\|in\|next\|not\|or\|redo\|rescue\|retry\|return\)\>[?!]\@!" | |
330 | -syn match rubyOperator "\<defined?" display | |
331 | -syn match rubyKeyword "\<\%(super\|yield\)\>[?!]\@!" | |
332 | -syn match rubyBoolean "\<\%(true\|false\)\>[?!]\@!" | |
333 | -syn match rubyPseudoVariable "\<\%(nil\|self\|__ENCODING__\|__dir__\|__FILE__\|__LINE__\|__callee__\|__method__\)\>[?!]\@!" " TODO: reorganise | |
334 | -syn match rubyBeginEnd "\<\%(BEGIN\|END\)\>[?!]\@!" | |
345 | +" TODO: reorganise | |
346 | +syn match rubyControl "\%#=1\<\%(break\|in\|next\|redo\|retry\|return\)\>" | |
347 | +syn match rubyKeyword "\%#=1\<\%(super\|yield\)\>" | |
348 | +syn match rubyBoolean "\%#=1\<\%(true\|false\)\>[?!]\@!" | |
349 | +syn match rubyPseudoVariable "\%#=1\<\(self\|nil\)\>[?!]\@!" | |
350 | +syn match rubyPseudoVariable "\%#=1\<__\%(ENCODING\|dir\|FILE\|LINE\|callee\|method\)__\>" | |
351 | +syn match rubyBeginEnd "\%#=1\<\%(BEGIN\|END\)\>" | |
335 | 352 | |
336 | 353 | " Expensive Mode {{{1 |
337 | 354 | " Match 'end' with the appropriate opening keyword for syntax based folding |
338 | 355 | " and special highlighting of module/class/method definitions |
339 | 356 | if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive") |
340 | - syn match rubyDefine "\<alias\>" nextgroup=rubyAliasDeclaration skipwhite skipnl | |
341 | - syn match rubyDefine "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl | |
342 | - syn match rubyDefine "\<undef\>" nextgroup=rubyMethodName skipwhite skipnl | |
343 | - syn match rubyClass "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl | |
344 | - syn match rubyModule "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl | |
357 | + syn match rubyDefine "\<alias\>" nextgroup=rubyAliasDeclaration skipwhite skipnl | |
358 | + syn match rubyDefine "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl | |
359 | + syn match rubyDefine "\<undef\>" nextgroup=rubyMethodName skipwhite skipnl | |
360 | + syn match rubyClass "\<class\>" nextgroup=rubyClassDeclaration,rubyEigenClassOperator skipwhite skipnl | |
361 | + syn match rubyModule "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl | |
345 | 362 | |
346 | - if s:foldable('def') | |
347 | - syn region rubyMethodBlock start="\<def\>" matchgroup=rubyDefine end="\%(\<def\_s\+\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop fold | |
348 | - else | |
349 | - syn region rubyMethodBlock start="\<def\>" matchgroup=rubyDefine end="\%(\<def\_s\+\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop | |
350 | - endif | |
351 | - | |
352 | - if s:foldable('class') | |
353 | - syn region rubyBlock start="\<class\>" matchgroup=rubyClass end="\<end\>" contains=ALLBUT,@rubyNotTop fold | |
354 | - else | |
355 | - syn region rubyBlock start="\<class\>" matchgroup=rubyClass end="\<end\>" contains=ALLBUT,@rubyNotTop | |
356 | - endif | |
357 | - | |
358 | - if s:foldable('module') | |
359 | - syn region rubyBlock start="\<module\>" matchgroup=rubyModule end="\<end\>" contains=ALLBUT,@rubyNotTop fold | |
360 | - else | |
361 | - syn region rubyBlock start="\<module\>" matchgroup=rubyModule end="\<end\>" contains=ALLBUT,@rubyNotTop | |
362 | - endif | |
363 | + SynFold 'def' syn region rubyMethodBlock start="\<def\>" matchgroup=rubyDefine skip="\<end:\|\%(\<def\_s\+\)\@<=end\>" end="\<end\>" contains=ALLBUT,@rubyNotTop | |
364 | + SynFold 'class' syn region rubyClassBlock start="\<class\>" matchgroup=rubyClass skip="\<end:" end="\<end\>" contains=ALLBUT,@rubyNotTop | |
365 | + SynFold 'module' syn region rubyModuleBlock start="\<module\>" matchgroup=rubyModule skip="\<end:" end="\<end\>" contains=ALLBUT,@rubyNotTop | |
363 | 366 | |
364 | 367 | " modifiers |
365 | - syn match rubyLineContinuation "\\$" nextgroup=rubyConditionalModifier,rubyRepeatModifier skipwhite skipnl | |
368 | + syn match rubyLineContinuation "\\$" nextgroup=@rubyModifier skipwhite skipnl | |
366 | 369 | syn match rubyConditionalModifier "\<\%(if\|unless\)\>" |
367 | 370 | syn match rubyRepeatModifier "\<\%(while\|until\)\>" |
371 | + syn match rubyRescueModifier "\<rescue\>" | |
368 | 372 | |
369 | - if s:foldable('do') | |
370 | - syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold | |
371 | - else | |
372 | - syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=ALLBUT,@rubyNotTop | |
373 | - endif | |
373 | + syn cluster rubyModifier contains=rubyConditionalModifier,rubyRepeatModifier,rubyRescueModifier | |
374 | + | |
375 | + SynFold 'do' syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" skip="\<end:" end="\<end\>" contains=ALLBUT,@rubyNotTop | |
374 | 376 | |
375 | 377 | " curly bracket block or hash literal |
376 | - if s:foldable('{') | |
377 | - syn region rubyCurlyBlock matchgroup=rubyCurlyBlockDelimiter start="{" end="}" contains=ALLBUT,@rubyNotTop fold | |
378 | - else | |
379 | - syn region rubyCurlyBlock matchgroup=rubyCurlyBlockDelimiter start="{" end="}" contains=ALLBUT,@rubyNotTop | |
380 | - endif | |
381 | - | |
382 | - if s:foldable('[') | |
383 | - syn region rubyArrayLiteral matchgroup=rubyArrayDelimiter start="\%(\w\|[\]})]\)\@<!\[" end="]" contains=ALLBUT,@rubyNotTop fold | |
384 | - endif | |
378 | + SynFold '{' syn region rubyCurlyBlock matchgroup=rubyCurlyBlockDelimiter start="{" end="}" contains=ALLBUT,@rubyNotTop | |
379 | + SynFold '[' syn region rubyArrayLiteral matchgroup=rubyArrayDelimiter start="\%(\%(\w\|[^\x00-\x7F]\)[?!]\=\|[]})]\)\@2<!\[" end="]" contains=ALLBUT,@rubyNotTop | |
385 | 380 | |
386 | 381 | " statements without 'do' |
387 | - if s:foldable('begin') | |
388 | - syn region rubyBlockExpression matchgroup=rubyControl start="\<begin\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold | |
389 | - else | |
390 | - syn region rubyBlockExpression matchgroup=rubyControl start="\<begin\>" end="\<end\>" contains=ALLBUT,@rubyNotTop | |
391 | - endif | |
382 | + SynFold 'begin' syn region rubyBlockExpression matchgroup=rubyControl start="\<begin\>" skip="\<end:" end="\<end\>" contains=ALLBUT,@rubyNotTop | |
383 | + SynFold 'case' syn region rubyCaseExpression matchgroup=rubyConditional start="\<case\>" skip="\<end:" end="\<end\>" contains=ALLBUT,@rubyNotTop | |
392 | 384 | |
393 | - if s:foldable('case') | |
394 | - syn region rubyCaseExpression matchgroup=rubyConditional start="\<case\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold | |
395 | - else | |
396 | - syn region rubyCaseExpression matchgroup=rubyConditional start="\<case\>" end="\<end\>" contains=ALLBUT,@rubyNotTop | |
397 | - endif | |
385 | + SynFold 'if' syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\<then\s\|\%(\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\@<![?!]\)\s*\)\@<=\%(if\|unless\)\>" skip="\<end:" end="\<end\>" contains=ALLBUT,@rubyNotTop | |
398 | 386 | |
399 | - if s:foldable('if') | |
400 | - syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![?!]\)\s*\)\@<=\%(if\|unless\)\>" end="\%(\%(\%(\.\@1<!\.\)\|::\)\s*\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop fold | |
401 | - else | |
402 | - syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![?!]\)\s*\)\@<=\%(if\|unless\)\>" end="\%(\%(\%(\.\@1<!\.\)\|::\)\s*\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop | |
403 | - endif | |
387 | + syn match rubyConditional "\<\%(then\|else\|when\)\>" contained containedin=rubyCaseExpression | |
388 | + syn match rubyConditional "\<\%(then\|else\|elsif\)\>" contained containedin=rubyConditionalExpression | |
404 | 389 | |
405 | - syn match rubyConditional "\<\%(then\|else\|when\)\>[?!]\@!" contained containedin=rubyCaseExpression | |
406 | - syn match rubyConditional "\<\%(then\|else\|elsif\)\>[?!]\@!" contained containedin=rubyConditionalExpression | |
407 | - | |
408 | - syn match rubyExceptional "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=rubyBlockExpression | |
409 | - syn match rubyMethodExceptional "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=rubyMethodBlock | |
390 | + syn match rubyExceptionHandler "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>" contained containedin=rubyBlockExpression,rubyDoBlock | |
391 | + syn match rubyExceptionHandler2 "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>" contained containedin=rubyModuleBlock,rubyClassBlock,rubyMethodBlock | |
392 | + syn cluster rubyExceptionHandler contains=rubyExceptionHandler,rubyExceptionHandler2 | |
410 | 393 | |
411 | 394 | " statements with optional 'do' |
412 | - syn region rubyOptionalDoLine matchgroup=rubyRepeat start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyOptionalDo end="\%(\<do\>\)" end="\ze\%(;\|$\)" oneline contains=ALLBUT,@rubyNotTop | |
395 | + syn region rubyOptionalDoLine matchgroup=rubyRepeat start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\@<![!?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyOptionalDo end="\<do\>" end="\ze\%(;\|$\)" oneline contains=ALLBUT,@rubyNotTop | |
413 | 396 | |
414 | - if s:foldable('for') | |
415 | - syn region rubyRepeatExpression start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat end="\<end\>" contains=ALLBUT,@rubyNotTop nextgroup=rubyOptionalDoLine fold | |
416 | - else | |
417 | - syn region rubyRepeatExpression start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat end="\<end\>" contains=ALLBUT,@rubyNotTop nextgroup=rubyOptionalDoLine | |
418 | - endif | |
397 | + SynFold 'for' syn region rubyRepeatExpression start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\@<![!?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat skip="\<end:" end="\<end\>" contains=ALLBUT,@rubyNotTop nextgroup=rubyOptionalDoLine | |
419 | 398 | |
420 | 399 | if !exists("ruby_minlines") |
421 | 400 | let ruby_minlines = 500 |
422 | 401 | endif |
423 | - exec "syn sync minlines=" . ruby_minlines | |
402 | + exe "syn sync minlines=" . ruby_minlines | |
424 | 403 | |
425 | 404 | else |
426 | - syn match rubyControl "\<def\>[?!]\@!" nextgroup=rubyMethodDeclaration skipwhite skipnl | |
427 | - syn match rubyControl "\<class\>[?!]\@!" nextgroup=rubyClassDeclaration skipwhite skipnl | |
428 | - syn match rubyControl "\<module\>[?!]\@!" nextgroup=rubyModuleDeclaration skipwhite skipnl | |
429 | - syn match rubyControl "\<\%(case\|begin\|do\|for\|if\|unless\|while\|until\|else\|elsif\|ensure\|then\|when\|end\)\>[?!]\@!" | |
430 | - syn match rubyKeyword "\<\%(alias\|undef\)\>[?!]\@!" | |
405 | + syn match rubyControl "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl | |
406 | + syn match rubyControl "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl | |
407 | + syn match rubyControl "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl | |
408 | + syn match rubyControl "\<\%(case\|begin\|do\|for\|if\|unless\|while\|until\|else\|elsif\|rescue\|ensure\|then\|when\|end\)\>" | |
409 | + syn match rubyKeyword "\<\%(alias\|undef\)\>" | |
431 | 410 | endif |
432 | 411 | |
433 | 412 | " Special Methods {{{1 |
434 | 413 | if !exists("ruby_no_special_methods") |
435 | - syn keyword rubyAccess public protected private public_class_method private_class_method public_constant private_constant module_function | |
436 | - " attr is a common variable name | |
437 | - syn match rubyAttribute "\%(\%(^\|;\)\s*\)\@<=attr\>\(\s*[.=]\)\@!" | |
438 | - syn keyword rubyAttribute attr_accessor attr_reader attr_writer | |
439 | - syn match rubyControl "\<\%(exit!\|\%(abort\|at_exit\|exit\|fork\|loop\|trap\)\>[?!]\@!\)" | |
440 | - syn keyword rubyEval eval class_eval instance_eval module_eval | |
441 | - syn keyword rubyException raise fail catch throw | |
442 | - syn keyword rubyInclude autoload gem load require require_relative | |
443 | - syn keyword rubyKeyword callcc caller lambda proc | |
444 | - " false positive with 'include?' | |
445 | - syn match rubyMacro "\<include\>[?!]\@!" | |
446 | - syn keyword rubyMacro extend prepend refine using | |
447 | - syn keyword rubyMacro alias_method define_method define_singleton_method remove_method undef_method | |
414 | + syn match rubyAccess "\<\%(public\|protected\|private\)\>" " use re=2 | |
415 | + syn match rubyAccess "\%#=1\<\%(public\|private\)_class_method\>" | |
416 | + syn match rubyAccess "\%#=1\<\%(public\|private\)_constant\>" | |
417 | + syn match rubyAccess "\%#=1\<module_function\>" | |
418 | + syn match rubyAttribute "\%#=1\%(\%(^\|;\)\s*\)\@<=attr\>\(\s*[.=]\)\@!" " attr is a common variable name | |
419 | + syn match rubyAttribute "\%#=1\<attr_\%(accessor\|reader\|writer\)\>" | |
420 | + syn match rubyControl "\%#=1\<\%(abort\|at_exit\|exit\|fork\|loop\|trap\)\>" | |
421 | + syn match rubyEval "\%#=1\<eval\>" | |
422 | + syn match rubyEval "\%#=1\<\%(class\|instance\|module\)_eval\>" | |
423 | + syn match rubyException "\%#=1\<\%(raise\|fail\|catch\|throw\)\>" | |
424 | + syn match rubyInclude "\%#=1\<\%(autoload\|gem\|load\|require\%(_relative\)\=\)\>" | |
425 | + syn match rubyKeyword "\%#=1\<\%(callcc\|caller\|lambda\|proc\)\>" | |
426 | + syn match rubyMacro "\%#=1\<\%(extend\|include\|prepend\|refine\|using\)\>" | |
427 | + syn match rubyMacro "\%#=1\<\%(alias\|define\|define_singleton\|remove\|undef\)_method\>" | |
448 | 428 | endif |
449 | 429 | |
450 | 430 | " Comments and Documentation {{{1 |
451 | -syn match rubySharpBang "\%^#!.*" display | |
452 | -syn keyword rubyTodo FIXME NOTE TODO OPTIMIZE HACK REVIEW XXX todo contained | |
453 | -syn match rubyComment "#.*" contains=rubySharpBang,rubySpaceError,rubyTodo,@Spell | |
431 | +syn match rubySharpBang "\%^#!.*" display | |
432 | +syn keyword rubyTodo FIXME NOTE TODO OPTIMIZE HACK REVIEW XXX todo contained | |
433 | +syn match rubyEncoding "[[:alnum:]-]\+" contained display | |
434 | +syn match rubyMagicComment "\c\%<3l#\s*\zs\%(coding\|encoding\):" contained nextgroup=rubyEncoding skipwhite | |
435 | +syn match rubyMagicComment "\c\%<10l#\s*\zs\%(frozen_string_literal\|warn_indent\|warn_past_scope\):" contained nextgroup=rubyBoolean skipwhite | |
436 | +syn match rubyComment "#.*" contains=@rubyCommentSpecial,rubySpaceError,@Spell | |
437 | + | |
438 | +syn cluster rubyCommentSpecial contains=rubySharpBang,rubyTodo,rubyMagicComment | |
439 | +syn cluster rubyCommentNotTop contains=@rubyCommentSpecial,rubyEncoding | |
440 | + | |
454 | 441 | if !exists("ruby_no_comment_fold") && s:foldable('#') |
455 | 442 | syn region rubyMultilineComment start="^\s*#.*\n\%(^\s*#\)\@=" end="^\s*#.*\n\%(^\s*#\)\@!" contains=rubyComment transparent fold keepend |
456 | - syn region rubyDocumentation start="^=begin\ze\%(\s.*\)\=$" end="^=end\%(\s.*\)\=$" contains=rubySpaceError,rubyTodo,@Spell fold | |
443 | + syn region rubyDocumentation start="^=begin\ze\%(\s.*\)\=$" end="^=end\%(\s.*\)\=$" contains=rubySpaceError,rubyTodo,@Spell fold | |
457 | 444 | else |
458 | - syn region rubyDocumentation start="^=begin\s*$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell | |
445 | + syn region rubyDocumentation start="^=begin\s*$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell | |
459 | 446 | endif |
460 | 447 | |
448 | +" {{{1 Useless Line Continuations | |
449 | +syn match rubyUselessLineContinuation "\%([.:,;{([<>~\*%&^|+=-]\|%(\%(\w\|[^\x00-\x7F]\)\@1<![?!]\)\s*\zs\\$" nextgroup=rubyUselessLineContinuation skipwhite skipempty | |
450 | +syn match rubyUselessLineContinuation "\\$" nextgroup=rubyUselessLineContinuation skipwhite skipempty contained | |
451 | + | |
461 | 452 | " Keyword Nobbling {{{1 |
462 | -" Note: this is a hack to prevent 'keywords' being highlighted as such when called as methods with an explicit receiver | |
463 | -syn match rubyKeywordAsMethod "\%(\%(\.\@1<!\.\)\|::\)\_s*\%([_[:lower:]][_[:alnum:]]*\|\<\%(BEGIN\|END\)\>\)" transparent contains=NONE | |
464 | -syn match rubyKeywordAsMethod "\(defined?\|exit!\)\@!\<[_[:lower:]][_[:alnum:]]*[?!]" transparent contains=NONE | |
453 | +" prevent methods with keyword names being highlighted as keywords when called | |
454 | +syn match rubyKeywordAsMethod "\%(\%(\.\@1<!\.\)\|&\.\|::\)\_s*\%([_[:lower:]][_[:alnum:]]*\|\%(BEGIN\|END\)\>\)" transparent contains=rubyDotOperator,rubyScopeOperator | |
465 | 455 | |
466 | -" More Symbols {{{1 | |
467 | -syn match rubySymbol "\%([{(,]\_s*\)\zs\l\w*[!?]\=::\@!"he=e-1 | |
468 | -syn match rubySymbol "[]})\"':]\@1<!\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],]\@="he=e-1 | |
469 | -syn match rubySymbol "\%([{(,]\_s*\)\zs[[:space:],{]\l\w*[!?]\=::\@!"hs=s+1,he=e-1 | |
470 | -syn match rubySymbol "[[:space:],{(]\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],]\@="hs=s+1,he=e-1 | |
456 | +" Bang and Predicate Methods and Operators {{{1 | |
457 | +syn match rubyBangPredicateMethod "\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[?!]" | |
458 | + | |
459 | +if !exists("ruby_no_special_methods") | |
460 | + syn match rubyControl "\%#=1\<exit!" display | |
461 | +endif | |
462 | +syn match rubyDefinedOperator "\%#=1\<defined?" display | |
463 | + | |
464 | +" 1.9-style Hash Keys and Keyword Parameters {{{1 | |
465 | +syn match rubySymbol "\%([{(|,]\_s*\)\@<=\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[?!]\=::\@!"he=e-1 | |
466 | +syn match rubySymbol "[]})\"':]\@1<!\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],;]\@="he=e-1 | |
467 | +syn match rubySymbol "[[:space:],{(]\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],;]\@="hs=s+1,he=e-1 | |
471 | 468 | |
472 | 469 | " __END__ Directive {{{1 |
473 | -if s:foldable('__END__') | |
474 | - syn region rubyData matchgroup=rubyDataDirective start="^__END__$" end="\%$" fold | |
475 | -else | |
476 | - syn region rubyData matchgroup=rubyDataDirective start="^__END__$" end="\%$" | |
477 | -endif | |
470 | +SynFold '__END__' syn region rubyData matchgroup=rubyDataDirective start="^__END__$" end="\%$" | |
478 | 471 | |
479 | 472 | " Default Highlighting {{{1 |
480 | 473 | hi def link rubyClass rubyDefine |
481 | 474 | hi def link rubyModule rubyDefine |
482 | -hi def link rubyMethodExceptional rubyDefine | |
475 | +hi def link rubyExceptionHandler2 rubyDefine | |
483 | 476 | hi def link rubyDefine Define |
484 | 477 | hi def link rubyAccess rubyMacro |
485 | 478 | hi def link rubyAttribute rubyMacro |
@@ -488,14 +481,15 @@ | ||
488 | 481 | hi def link rubyFunction Function |
489 | 482 | hi def link rubyConditional Conditional |
490 | 483 | hi def link rubyConditionalModifier rubyConditional |
491 | -hi def link rubyExceptional rubyConditional | |
484 | +hi def link rubyExceptionHandler rubyConditional | |
485 | +hi def link rubyRescueModifier rubyExceptionHandler | |
492 | 486 | hi def link rubyRepeat Repeat |
493 | 487 | hi def link rubyRepeatModifier rubyRepeat |
494 | 488 | hi def link rubyOptionalDo rubyRepeat |
495 | 489 | hi def link rubyControl Statement |
496 | 490 | hi def link rubyInclude Include |
497 | 491 | hi def link rubyInteger Number |
498 | -hi def link rubyASCIICode Character | |
492 | +hi def link rubyCharacter Character | |
499 | 493 | hi def link rubyFloat Float |
500 | 494 | hi def link rubyBoolean Boolean |
501 | 495 | hi def link rubyException Exception |
@@ -515,39 +509,80 @@ | ||
515 | 509 | hi def link rubyPredefinedVariable rubyPredefinedIdentifier |
516 | 510 | hi def link rubySymbol Constant |
517 | 511 | hi def link rubyKeyword Keyword |
512 | + | |
518 | 513 | hi def link rubyOperator Operator |
514 | +hi def link rubyDefinedOperator rubyOperator | |
515 | +hi def link rubyEnglishBooleanOperator rubyOperator | |
516 | +if exists("ruby_operators") | |
517 | + hi def link rubyTernaryOperator rubyOperator | |
518 | + hi def link rubyArithmeticOperator rubyOperator | |
519 | + hi def link rubyComparisonOperator rubyOperator | |
520 | + hi def link rubyBitwiseOperator rubyOperator | |
521 | + hi def link rubyBooleanOperator rubyOperator | |
522 | + hi def link rubyRangeOperator rubyOperator | |
523 | + hi def link rubyAssignmentOperator rubyOperator | |
524 | + hi def link rubyEqualityOperator rubyOperator | |
525 | +endif | |
526 | + | |
527 | +if exists("ruby_pseudo_operators") | |
528 | + hi def link rubyPseudoOperator Special | |
529 | + hi def link rubyDotOperator rubyPseudoOperator | |
530 | + hi def link rubyScopeOperator rubyPseudoOperator | |
531 | + hi def link rubySuperClassOperator rubyPseudoOperator | |
532 | + hi def link rubyEigenClassOperator rubyPseudoOperator | |
533 | + hi def link rubyLambdaOperator rubyPseudoOperator | |
534 | + hi def link rubyDoubleSplatOperator rubyPseudoOperator | |
535 | + hi def link rubySplatOperator rubyPseudoOperator | |
536 | + hi def link rubyProcOperator rubyPseudoOperator | |
537 | +endif | |
538 | + | |
519 | 539 | hi def link rubyBeginEnd Statement |
520 | 540 | hi def link rubyEval Statement |
521 | 541 | hi def link rubyPseudoVariable Constant |
522 | -hi def link rubyCapitalizedMethod rubyLocalVariableOrMethod | |
542 | +hi def link rubyCapitalizedMethod NONE | |
523 | 543 | |
524 | 544 | hi def link rubyComment Comment |
545 | +hi def link rubyEncoding Constant | |
546 | +hi def link rubyMagicComment SpecialComment | |
525 | 547 | hi def link rubyData Comment |
526 | 548 | hi def link rubyDataDirective Delimiter |
527 | 549 | hi def link rubyDocumentation Comment |
528 | 550 | hi def link rubyTodo Todo |
529 | 551 | |
552 | +hi def link rubyBackslashEscape rubyStringEscape | |
530 | 553 | hi def link rubyQuoteEscape rubyStringEscape |
554 | +hi def link rubySpaceEscape rubyStringEscape | |
555 | +hi def link rubyParenthesisEscape rubyStringEscape | |
556 | +hi def link rubyCurlyBraceEscape rubyStringEscape | |
557 | +hi def link rubyAngleBracketEscape rubyStringEscape | |
558 | +hi def link rubySquareBracketEscape rubyStringEscape | |
531 | 559 | hi def link rubyStringEscape Special |
560 | + | |
532 | 561 | hi def link rubyInterpolationDelimiter Delimiter |
533 | -hi def link rubyNoInterpolation rubyString | |
534 | 562 | hi def link rubySharpBang PreProc |
563 | +hi def link rubyStringDelimiter Delimiter | |
564 | +hi def link rubyHeredocDelimiter rubyStringDelimiter | |
565 | +hi def link rubyPercentRegexpDelimiter rubyRegexpDelimiter | |
566 | +hi def link rubyPercentStringDelimiter rubyStringDelimiter | |
567 | +hi def link rubyPercentSymbolDelimiter rubySymbolDelimiter | |
535 | 568 | hi def link rubyRegexpDelimiter rubyStringDelimiter |
536 | 569 | hi def link rubySymbolDelimiter rubySymbol |
537 | -hi def link rubyStringDelimiter Delimiter | |
538 | -hi def link rubyHeredoc rubyString | |
539 | 570 | hi def link rubyString String |
540 | 571 | hi def link rubyRegexpEscape rubyRegexpSpecial |
541 | 572 | hi def link rubyRegexpQuantifier rubyRegexpSpecial |
542 | 573 | hi def link rubyRegexpAnchor rubyRegexpSpecial |
543 | 574 | hi def link rubyRegexpDot rubyRegexpCharClass |
544 | 575 | hi def link rubyRegexpCharClass rubyRegexpSpecial |
576 | +hi def link rubyRegexpIntersection rubyRegexpSpecial | |
545 | 577 | hi def link rubyRegexpSpecial Special |
546 | 578 | hi def link rubyRegexpComment Comment |
547 | 579 | hi def link rubyRegexp rubyString |
548 | 580 | |
549 | -hi def link rubyInvalidVariable Error | |
550 | 581 | hi def link rubyError Error |
582 | +if exists("ruby_line_continuation_error") | |
583 | + hi def link rubyUselessLineContinuation rubyError | |
584 | +endif | |
585 | +hi def link rubyGlobalVariableError rubyError | |
551 | 586 | hi def link rubySpaceError rubyError |
552 | 587 | |
553 | 588 | " Postscript {{{1 |
@@ -556,4 +591,6 @@ | ||
556 | 591 | let &cpo = s:cpo_sav |
557 | 592 | unlet! s:cpo_sav |
558 | 593 | |
594 | +delc SynFold | |
595 | + | |
559 | 596 | " vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: |