Permalink
Browse files

add in support for eco templates

  • Loading branch information...
1 parent b9b4407 commit 938a265eff43685e42576bf403377ce0638f4ad6 @jneen jneen committed Mar 4, 2011
Showing with 63 additions and 0 deletions.
  1. +1 −0 ftdetect/eco.vim
  2. +62 −0 syntax/eco.vim
View
@@ -0,0 +1 @@
+autocmd BufNewFile,BufRead *.eco set filetype=eco
View
@@ -0,0 +1,62 @@
+" Vim syntax file
+" Language: eco
+" Maintainer: Jay Adkisson
+" Mostly stolen from eruby.vim
+
+if !exists("g:eco_default_subtype")
+ let g:eco_default_subtype = "html"
+endif
+
+if !exists("b:eco_subtype")
+ let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
+ let b:eco_subtype = matchstr(s:lines,'eco_subtype=\zs\w\+')
+ if b:eco_subtype == ''
+ let b:eco_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eco\)\+$','',''),'\.\zs\w\+$')
+ endif
+ if b:eco_subtype == 'rhtml'
+ let b:eco_subtype = 'html'
+ elseif b:eco_subtype == 'rb'
+ let b:eco_subtype = 'ruby'
+ elseif b:eco_subtype == 'yml'
+ let b:eco_subtype = 'yaml'
+ elseif b:eco_subtype == 'js'
+ let b:eco_subtype = 'javascript'
+ elseif b:eco_subtype == 'txt'
+ " Conventional; not a real file type
+ let b:eco_subtype = 'text'
+ elseif b:eco_subtype == ''
+ if b:current_syntax == ''
+ let b:eco_subtype = g:eco_default_subtype
+ else
+ let b:eco_subtype = b:current_syntax
+ endif
+ endif
+endif
+
+if exists("b:eruby_subtype") && b:eruby_subtype != ''
+ exec "runtime! syntax/".b:eruby_subtype.".vim"
+ let b:current_syntax = "eco"
+endif
+
+syn include @coffeeTop syntax/coffee.vim
+
+syn cluster ecoRegions contains=ecoBlock,ecoExpression,ecoComment
+
+syn region ecoBlock matchgroup=ecoDelimiter start=/<%/ end=/%>/ contains=@coffeeTop containedin=ALLBUT,@ecoRegions keepend
+syn region ecoExpression matchgroup=ecoDelimiter start=/<%[=\-]/ end=/%>/ contains=@coffeeTop containedin=ALLBUT,@ecoRegions keepend
+syn region ecoComment matchgroup=ecoComment start=/<%#/ end=/%>/ contains=@coffeeTodo,@Spell containedin=ALLBUT,@ecoRegions keepend
+
+" eco features not in coffeescript proper
+syn keyword ecoEnd end containedin=@ecoRegions
+syn match ecoIndentColon /\s+\w+:/ containedin=@ecoRegions
+
+" Define the default highlighting.
+
+hi def link ecoDelimiter Delimiter
+hi def link ecoComment Comment
+hi def link ecoEnd coffeeConditional
+hi def link ecoIndentColon None
+
+let b:current_syntax = 'eco'
+
+" vim: nowrap sw=2 sts=2 ts=8:

0 comments on commit 938a265

Please sign in to comment.