Mercurial > hg > RemoteEditor > vim7
comparison runtime/syntax/eruby.vim @ 0:76efa0be13f1
Initial revision
author | atsuki |
---|---|
date | Sat, 10 Nov 2007 15:07:22 +0900 |
parents | |
children | 6a13985590e6 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:76efa0be13f1 |
---|---|
1 " Vim syntax file | |
2 " Language: eRuby | |
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.info> | |
4 " Info: $Id$ | |
5 " URL: http://vim-ruby.rubyforge.org | |
6 " Anon CVS: See above site | |
7 " Release Coordinator: Doug Kearns <dougkearns@gmail.com> | |
8 | |
9 if exists("b:current_syntax") | |
10 finish | |
11 endif | |
12 | |
13 if !exists("main_syntax") | |
14 let main_syntax = 'eruby' | |
15 endif | |
16 | |
17 if !exists("g:eruby_default_subtype") | |
18 let g:eruby_default_subtype = "html" | |
19 endif | |
20 | |
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 == '' | |
25 let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\)\+$','',''),'\.\zs\w\+$') | |
26 endif | |
27 if b:eruby_subtype == 'rhtml' | |
28 let b:eruby_subtype = 'html' | |
29 elseif b:eruby_subtype == 'rb' | |
30 let b:eruby_subtype = 'ruby' | |
31 elseif b:eruby_subtype == 'yml' | |
32 let b:eruby_subtype = 'yaml' | |
33 elseif b:eruby_subtype == 'js' | |
34 let b:eruby_subtype = 'javascript' | |
35 elseif b:eruby_subtype == 'txt' | |
36 " Conventional; not a real file type | |
37 let b:eruby_subtype = 'text' | |
38 elseif b:eruby_subtype == '' | |
39 let b:eruby_subtype = g:eruby_default_subtype | |
40 endif | |
41 endif | |
42 | |
43 if !exists("b:eruby_nest_level") | |
44 let b:eruby_nest_level = strlen(substitute(substitute(substitute(expand("%:t"),'@','','g'),'\c\.\%(erb\|rhtml\)\>','@','g'),'[^@]','','g')) | |
45 endif | |
46 if !b:eruby_nest_level | |
47 let b:eruby_nest_level = 1 | |
48 endif | |
49 | |
50 if exists("b:eruby_subtype") && b:eruby_subtype != '' | |
51 exe "runtime! syntax/".b:eruby_subtype.".vim" | |
52 unlet! b:current_syntax | |
53 endif | |
54 syn include @rubyTop syntax/ruby.vim | |
55 | |
56 syn cluster erubyRegions contains=erubyOneLiner,erubyBlock,erubyExpression,erubyComment | |
57 | |
58 exe 'syn region erubyOneLiner matchgroup=erubyDelimiter start="^%\{1,'.b:eruby_nest_level.'\}%\@!" end="$" contains=@rubyTop containedin=ALLBUT,@erbRegions keepend oneline' | |
59 exe 'syn region erubyBlock matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}%\@!-\=" end="-\=%>" contains=@rubyTop containedin=ALLBUT,@erbRegions' | |
60 exe 'syn region erubyExpression matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}=" end="-\=%>" contains=@rubyTop containedin=ALLBUT,@erbRegions' | |
61 exe 'syn region erubyComment matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}#" end="-\=%>" contains=rubyTodo,@Spell containedin=ALLBUT,@erbRegions keepend' | |
62 | |
63 " Define the default highlighting. | |
64 " For version 5.7 and earlier: only when not done already | |
65 " For version 5.8 and later: only when an item doesn't have highlighting yet | |
66 if version >= 508 || !exists("did_eruby_syntax_inits") | |
67 if version < 508 | |
68 let did_ruby_syntax_inits = 1 | |
69 command -nargs=+ HiLink hi link <args> | |
70 else | |
71 command -nargs=+ HiLink hi def link <args> | |
72 endif | |
73 | |
74 HiLink erubyDelimiter Delimiter | |
75 HiLink erubyComment Comment | |
76 | |
77 delcommand HiLink | |
78 endif | |
79 let b:current_syntax = 'eruby' | |
80 | |
81 if main_syntax == 'eruby' | |
82 unlet main_syntax | |
83 endif | |
84 | |
85 " vim: nowrap sw=2 sts=2 ts=8 ff=unix: |