497
|
1 " Vim syntax file
|
831
|
2 " Language: eRuby
|
2225
|
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
4869
|
4 " URL: https://github.com/vim-ruby/vim-ruby
|
831
|
5 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
15512
|
6 " Last Change: 2018 Jul 04
|
497
|
7
|
15512
|
8 if &syntax !~# '\<eruby\>' || get(b:, 'current_syntax') =~# '\<eruby\>'
|
497
|
9 finish
|
|
10 endif
|
|
11
|
|
12 if !exists("main_syntax")
|
|
13 let main_syntax = 'eruby'
|
|
14 endif
|
|
15
|
1214
|
16 if !exists("g:eruby_default_subtype")
|
|
17 let g:eruby_default_subtype = "html"
|
497
|
18 endif
|
|
19
|
4869
|
20 if &filetype =~ '^eruby\.'
|
|
21 let b:eruby_subtype = matchstr(&filetype,'^eruby\.\zs\w\+')
|
15512
|
22 elseif &filetype =~ '^.*\.eruby\>'
|
|
23 let b:eruby_subtype = matchstr(&filetype,'^.\{-\}\ze\.eruby\>')
|
4869
|
24 elseif !exists("b:eruby_subtype") && main_syntax == 'eruby'
|
1214
|
25 let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
|
|
26 let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+')
|
|
27 if b:eruby_subtype == ''
|
15512
|
28 let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\|\.example\)\+$','',''),'\.\zs\w\+\%(\ze+\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")
|
15512
|
47 if &syntax =~# '\<eruby\.eruby\>'
|
|
48 let b:eruby_nest_level = strlen(substitute(substitute(&filetype,'\C\<eruby\>','@','g'),'[^@]','','g'))
|
|
49 else
|
|
50 let b:eruby_nest_level = strlen(substitute(substitute(substitute(expand("%:t"),'@','','g'),'\c\.\%(erb\|rhtml\)\>','@','g'),'[^@]','','g'))
|
|
51 endif
|
1214
|
52 endif
|
|
53 if !b:eruby_nest_level
|
|
54 let b:eruby_nest_level = 1
|
|
55 endif
|
|
56
|
15512
|
57 if get(b:, 'eruby_subtype', '') !~# '^\%(eruby\)\=$' && &syntax =~# '^eruby\>'
|
1214
|
58 exe "runtime! syntax/".b:eruby_subtype.".vim"
|
|
59 endif
|
15512
|
60 unlet! b:current_syntax
|
1214
|
61 syn include @rubyTop syntax/ruby.vim
|
|
62
|
530
|
63 syn cluster erubyRegions contains=erubyOneLiner,erubyBlock,erubyExpression,erubyComment
|
|
64
|
1668
|
65 exe 'syn region erubyOneLiner matchgroup=erubyDelimiter start="^%\{1,'.b:eruby_nest_level.'\}%\@!" end="$" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend oneline'
|
2225
|
66 exe 'syn region erubyBlock matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}%\@!-\=" end="[=-]\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend'
|
|
67 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'
|
4869
|
68 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
|
69
|
|
70 " Define the default highlighting.
|
|
71
|
2225
|
72 hi def link erubyDelimiter PreProc
|
1668
|
73 hi def link erubyComment Comment
|
497
|
74
|
15512
|
75 let b:current_syntax = matchstr(&syntax, '^.*\<eruby\>')
|
497
|
76
|
|
77 if main_syntax == 'eruby'
|
|
78 unlet main_syntax
|
|
79 endif
|
|
80
|
1668
|
81 " vim: nowrap sw=2 sts=2 ts=8:
|