Skip to content
Newer
Older
100644 75 lines (61 sloc) 2.84 KB
0cce2bd @dkearns add syntax highlighting for eRuby files
dkearns authored Aug 11, 2005
1 " Vim syntax file
1859099 @tpope Add subtype support to indent/eruby.vim
tpope authored Apr 16, 2007
2 " Language: eRuby
2dd56d6 @tpope Update Tim Pope's email
tpope authored Dec 22, 2009
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
699670a @dkearns Update all RubyForge URLs with new GitHub equivalents.
dkearns authored Mar 21, 2011
4 " URL: https://github.com/vim-ruby/vim-ruby
ad3a6a9 @dkearns add Release-Coordinator header line and remove GPL license
dkearns authored Apr 15, 2006
5 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
0cce2bd @dkearns add syntax highlighting for eRuby files
dkearns authored Aug 11, 2005
6
7c94a16 @dkearns remove the Vim version 5 compatibility code
dkearns authored Mar 20, 2007
7 if exists("b:current_syntax")
ea30586 @tpope Early support for eruby subtypes
tpope authored Apr 16, 2007
8 finish
0cce2bd @dkearns add syntax highlighting for eRuby files
dkearns authored Aug 11, 2005
9 endif
10
11 if !exists("main_syntax")
12 let main_syntax = 'eruby'
13 endif
14
1ad4c67 @tpope default eruby subtype option
tpope authored May 6, 2007
15 if !exists("g:eruby_default_subtype")
16 let g:eruby_default_subtype = "html"
17 endif
18
8ee9e43 @tpope Give higher precedence to eruby.foo subtype
tpope authored Dec 19, 2010
19 if &filetype =~ '^eruby\.'
20 let b:eruby_subtype = matchstr(&filetype,'^eruby\.\zs\w\+')
21 elseif !exists("b:eruby_subtype") && main_syntax == 'eruby'
ea30586 @tpope Early support for eruby subtypes
tpope authored Apr 16, 2007
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\+')
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored Apr 17, 2007
24 if b:eruby_subtype == ''
b27a75b @tpope Support Rails html+tablet style extensions
tpope authored Sep 17, 2014
25 let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$')
ea30586 @tpope Early support for eruby subtypes
tpope authored Apr 16, 2007
26 endif
27 if b:eruby_subtype == 'rhtml'
28 let b:eruby_subtype = 'html'
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored Apr 17, 2007
29 elseif b:eruby_subtype == 'rb'
30 let b:eruby_subtype = 'ruby'
ea30586 @tpope Early support for eruby subtypes
tpope authored Apr 16, 2007
31 elseif b:eruby_subtype == 'yml'
32 let b:eruby_subtype = 'yaml'
5d28285 @tpope Refined eRuby subtype detection
tpope authored Apr 20, 2007
33 elseif b:eruby_subtype == 'js'
34 let b:eruby_subtype = 'javascript'
ea30586 @tpope Early support for eruby subtypes
tpope authored Apr 16, 2007
35 elseif b:eruby_subtype == 'txt'
36 " Conventional; not a real file type
37 let b:eruby_subtype = 'text'
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored Apr 17, 2007
38 elseif b:eruby_subtype == ''
1ad4c67 @tpope default eruby subtype option
tpope authored May 6, 2007
39 let b:eruby_subtype = g:eruby_default_subtype
ea30586 @tpope Early support for eruby subtypes
tpope authored Apr 16, 2007
40 endif
41 endif
42
51fa67d @tpope NEWS; allow for eruby nesting
tpope authored May 6, 2007
43 if !exists("b:eruby_nest_level")
c032902 @tpope Last minute updates before release
tpope authored May 6, 2007
44 let b:eruby_nest_level = strlen(substitute(substitute(substitute(expand("%:t"),'@','','g'),'\c\.\%(erb\|rhtml\)\>','@','g'),'[^@]','','g'))
51fa67d @tpope NEWS; allow for eruby nesting
tpope authored May 6, 2007
45 endif
46 if !b:eruby_nest_level
47 let b:eruby_nest_level = 1
48 endif
49
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored Apr 17, 2007
50 if exists("b:eruby_subtype") && b:eruby_subtype != ''
51 exe "runtime! syntax/".b:eruby_subtype.".vim"
52 unlet! b:current_syntax
0cce2bd @dkearns add syntax highlighting for eRuby files
dkearns authored Aug 11, 2005
53 endif
653a80b @tpope Support for a subtype in ftplugin/eruby.vim
tpope authored Apr 17, 2007
54 syn include @rubyTop syntax/ruby.vim
0cce2bd @dkearns add syntax highlighting for eRuby files
dkearns authored Aug 11, 2005
55
2765ade @dkearns make sure escaped eRuby tags aren't highlighted as block delimiters w…
dkearns authored Sep 13, 2005
56 syn cluster erubyRegions contains=erubyOneLiner,erubyBlock,erubyExpression,erubyComment
57
e248f61 @tpope Fixed ALLBUT clauses to refer to right group
tpope authored Jul 14, 2007
58 exe 'syn region erubyOneLiner matchgroup=erubyDelimiter start="^%\{1,'.b:eruby_nest_level.'\}%\@!" end="$" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend oneline'
adc6435 @tpope Highlight <%== and =%> from Erubis
tpope authored Jan 23, 2009
59 exe 'syn region erubyBlock matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}%\@!-\=" end="[=-]\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend'
60 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'
b10adca @tpope Highlight <%-# comments -%>
tpope authored Aug 17, 2012
61 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'
7c94a16 @dkearns remove the Vim version 5 compatibility code
dkearns authored Mar 20, 2007
62
ea30586 @tpope Early support for eruby subtypes
tpope authored Apr 16, 2007
63 " Define the default highlighting.
7c94a16 @dkearns remove the Vim version 5 compatibility code
dkearns authored Mar 20, 2007
64
3aadc87 @tpope Highlight eRuby delimiters as PreProc
tpope authored Feb 26, 2010
65 hi def link erubyDelimiter PreProc
f517c02 @tpope Highlight negative sign; remove Vim 5.x stuff
tpope authored Sep 6, 2007
66 hi def link erubyComment Comment
ea30586 @tpope Early support for eruby subtypes
tpope authored Apr 16, 2007
67
68 let b:current_syntax = 'eruby'
0cce2bd @dkearns add syntax highlighting for eRuby files
dkearns authored Aug 11, 2005
69
70 if main_syntax == 'eruby'
71 unlet main_syntax
72 endif
73
b2d3cba @tpope indent/eruby.vim: fix quirk in optional argument handling
tpope authored Jun 29, 2008
74 " vim: nowrap sw=2 sts=2 ts=8:
Something went wrong with that request. Please try again.