497
|
1 " Vim syntax file
|
831
|
2 " Language: eRuby
|
2225
|
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
|
4 " Last Change: 2010 Apr 15
|
831
|
5 " URL: http://vim-ruby.rubyforge.org
|
|
6 " Anon CVS: See above site
|
|
7 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
497
|
8
|
1214
|
9 if exists("b:current_syntax")
|
497
|
10 finish
|
|
11 endif
|
|
12
|
|
13 if !exists("main_syntax")
|
|
14 let main_syntax = 'eruby'
|
|
15 endif
|
|
16
|
1214
|
17 if !exists("g:eruby_default_subtype")
|
|
18 let g:eruby_default_subtype = "html"
|
497
|
19 endif
|
|
20
|
1214
|
21 if !exists("b:eruby_subtype") && main_syntax == 'eruby'
|
|
22 let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
|
|
23 let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+')
|
|
24 if b:eruby_subtype == ''
|
2225
|
25 let b:eruby_subtype = matchstr(&filetype,'^eruby\.\zs\w\+')
|
|
26 endif
|
|
27 if b:eruby_subtype == ''
|
|
28 let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\)\+$','',''),'\.\zs\w\+$')
|
1214
|
29 endif
|
|
30 if b:eruby_subtype == 'rhtml'
|
|
31 let b:eruby_subtype = 'html'
|
|
32 elseif b:eruby_subtype == 'rb'
|
|
33 let b:eruby_subtype = 'ruby'
|
|
34 elseif b:eruby_subtype == 'yml'
|
|
35 let b:eruby_subtype = 'yaml'
|
|
36 elseif b:eruby_subtype == 'js'
|
|
37 let b:eruby_subtype = 'javascript'
|
|
38 elseif b:eruby_subtype == 'txt'
|
|
39 " Conventional; not a real file type
|
|
40 let b:eruby_subtype = 'text'
|
|
41 elseif b:eruby_subtype == ''
|
|
42 let b:eruby_subtype = g:eruby_default_subtype
|
|
43 endif
|
|
44 endif
|
|
45
|
|
46 if !exists("b:eruby_nest_level")
|
|
47 let b:eruby_nest_level = strlen(substitute(substitute(substitute(expand("%:t"),'@','','g'),'\c\.\%(erb\|rhtml\)\>','@','g'),'[^@]','','g'))
|
|
48 endif
|
|
49 if !b:eruby_nest_level
|
|
50 let b:eruby_nest_level = 1
|
|
51 endif
|
|
52
|
|
53 if exists("b:eruby_subtype") && b:eruby_subtype != ''
|
|
54 exe "runtime! syntax/".b:eruby_subtype.".vim"
|
|
55 unlet! b:current_syntax
|
|
56 endif
|
|
57 syn include @rubyTop syntax/ruby.vim
|
|
58
|
530
|
59 syn cluster erubyRegions contains=erubyOneLiner,erubyBlock,erubyExpression,erubyComment
|
|
60
|
1668
|
61 exe 'syn region erubyOneLiner matchgroup=erubyDelimiter start="^%\{1,'.b:eruby_nest_level.'\}%\@!" end="$" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend oneline'
|
2225
|
62 exe 'syn region erubyBlock matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}%\@!-\=" end="[=-]\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend'
|
|
63 exe 'syn region erubyExpression matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}=\{1,4}" end="[=-]\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend'
|
|
64 exe 'syn region erubyComment matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}#" end="%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=rubyTodo,@Spell containedin=ALLBUT,@erubyRegions keepend'
|
497
|
65
|
|
66 " Define the default highlighting.
|
|
67
|
2225
|
68 hi def link erubyDelimiter PreProc
|
1668
|
69 hi def link erubyComment Comment
|
497
|
70
|
1214
|
71 let b:current_syntax = 'eruby'
|
497
|
72
|
|
73 if main_syntax == 'eruby'
|
|
74 unlet main_syntax
|
|
75 endif
|
|
76
|
1668
|
77 " vim: nowrap sw=2 sts=2 ts=8:
|