]> git.r.bdr.sh - rbdr/dotfiles/blob - vim/syntax/eco.vim
485b356eaa099ceed0ed4dad9b6289d7cf8aff6e
[rbdr/dotfiles] / vim / syntax / eco.vim
1 " Vim syntax file
2 " Language: eco
3 " Maintainer: Jay Adkisson
4 " Mostly stolen from eruby.vim
5
6 if !exists("g:eco_default_subtype")
7 let g:eco_default_subtype = "html"
8 endif
9
10 if !exists("b:eco_subtype")
11 let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
12 let b:eco_subtype = matchstr(s:lines,'eco_subtype=\zs\w\+')
13 if b:eco_subtype == ''
14 let b:eco_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.eco\)\+$','',''),'\.\zs\w\+$')
15 endif
16 if b:eco_subtype == 'rhtml'
17 let b:eco_subtype = 'html'
18 elseif b:eco_subtype == 'jst'
19 let b:eco_subtype = 'html'
20 elseif b:eco_subtype == 'rb'
21 let b:eco_subtype = 'ruby'
22 elseif b:eco_subtype == 'yml'
23 let b:eco_subtype = 'yaml'
24 elseif b:eco_subtype == 'js' || b:eco_subtype == 'json'
25 let b:eco_subtype = 'javascript'
26 elseif b:eco_subtype == 'txt'
27 " Conventional; not a real file type
28 let b:eco_subtype = 'text'
29 elseif b:eco_subtype == ''
30 if exists('b:current_syntax') && b:current_syntax != ''
31 let b:eco_subtype = b:current_syntax
32 else
33 let b:eco_subtype = g:eco_default_subtype
34 endif
35 endif
36 endif
37
38 if exists("b:eco_subtype") && b:eco_subtype != '' && b:eco_subtype != 'eco'
39 exec "runtime! syntax/".b:eco_subtype.".vim"
40 syn include @coffeeTop syntax/coffee.vim
41 endif
42
43 syn cluster ecoRegions contains=ecoBlock,ecoExpression,ecoComment
44
45 syn region ecoBlock matchgroup=ecoDelimiter start=/<%/ end=/%>/ contains=@coffeeTop containedin=ALLBUT,@ecoRegions keepend
46 syn region ecoExpression matchgroup=ecoDelimiter start=/<%[=\-]/ end=/%>/ contains=@coffeeTop containedin=ALLBUT,@ecoRegions keepend
47 syn region ecoComment matchgroup=ecoComment start=/<%#/ end=/%>/ contains=@coffeeTodo,@Spell containedin=ALLBUT,@ecoRegions keepend
48
49 " eco features not in coffeescript proper
50 syn keyword ecoEnd end containedin=@ecoRegions
51 syn match ecoIndentColon /\s+\w+:/ containedin=@ecoRegions
52
53 " Define the default highlighting.
54
55 hi def link ecoDelimiter Delimiter
56 hi def link ecoComment Comment
57 hi def link ecoEnd coffeeConditional
58 hi def link ecoIndentColon None
59
60 let b:current_syntax = 'eco'
61
62 " vim: nowrap sw=2 sts=2 ts=8: