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>
|
28246
|
6 " Last Change: 2022 Mar 18
|
497
|
7
|
28246
|
8 if exists("b:current_syntax")
|
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\+')
|
|
22 elseif !exists("b:eruby_subtype") && main_syntax == 'eruby'
|
1214
|
23 let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
|
|
24 let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+')
|
|
25 if b:eruby_subtype == ''
|
15512
|
26 let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\|\.example\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$')
|
1214
|
27 endif
|
|
28 if b:eruby_subtype == 'rhtml'
|
|
29 let b:eruby_subtype = 'html'
|
|
30 elseif b:eruby_subtype == 'rb'
|
|
31 let b:eruby_subtype = 'ruby'
|
|
32 elseif b:eruby_subtype == 'yml'
|
|
33 let b:eruby_subtype = 'yaml'
|
|
34 elseif b:eruby_subtype == 'js'
|
|
35 let b:eruby_subtype = 'javascript'
|
|
36 elseif b:eruby_subtype == 'txt'
|
|
37 " Conventional; not a real file type
|
|
38 let b:eruby_subtype = 'text'
|
|
39 elseif b:eruby_subtype == ''
|
|
40 let b:eruby_subtype = g:eruby_default_subtype
|
|
41 endif
|
|
42 endif
|
|
43
|
|
44 if !exists("b:eruby_nest_level")
|
15512
|
45 if &syntax =~# '\<eruby\.eruby\>'
|
|
46 let b:eruby_nest_level = strlen(substitute(substitute(&filetype,'\C\<eruby\>','@','g'),'[^@]','','g'))
|
|
47 else
|
|
48 let b:eruby_nest_level = strlen(substitute(substitute(substitute(expand("%:t"),'@','','g'),'\c\.\%(erb\|rhtml\)\>','@','g'),'[^@]','','g'))
|
|
49 endif
|
1214
|
50 endif
|
|
51 if !b:eruby_nest_level
|
|
52 let b:eruby_nest_level = 1
|
|
53 endif
|
|
54
|
28246
|
55 if exists("b:eruby_subtype") && b:eruby_subtype != '' && b:eruby_subtype !=? 'eruby'
|
1214
|
56 exe "runtime! syntax/".b:eruby_subtype.".vim"
|
28246
|
57 unlet! b:current_syntax
|
1214
|
58 endif
|
|
59 syn include @rubyTop syntax/ruby.vim
|
|
60
|
530
|
61 syn cluster erubyRegions contains=erubyOneLiner,erubyBlock,erubyExpression,erubyComment
|
|
62
|
1668
|
63 exe 'syn region erubyOneLiner matchgroup=erubyDelimiter start="^%\{1,'.b:eruby_nest_level.'\}%\@!" end="$" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend oneline'
|
2225
|
64 exe 'syn region erubyBlock matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}%\@!-\=" end="[=-]\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend'
|
|
65 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
|
66 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
|
67
|
|
68 " Define the default highlighting.
|
|
69
|
2225
|
70 hi def link erubyDelimiter PreProc
|
1668
|
71 hi def link erubyComment Comment
|
497
|
72
|
28246
|
73 let b:current_syntax = 'eruby'
|
497
|
74
|
|
75 if main_syntax == 'eruby'
|
|
76 unlet main_syntax
|
|
77 endif
|
|
78
|
1668
|
79 " vim: nowrap sw=2 sts=2 ts=8:
|