]> git.r.bdr.sh - rbdr/dotfiles/blob - vim/syntax/mustache.vim
Update vim plugins
[rbdr/dotfiles] / vim / syntax / mustache.vim
1 " Vim syntax file
2 " Language: Mustache
3 " Maintainer: Juvenn Woo <machese@gmail.com>
4 " Screenshot: http://imgur.com/6F408
5 " Version: 1
6 " Last Change: 2009 Oct 15
7 " Remark:
8 " It lexically hilights embedded mustaches (exclusively) in html file.
9 " While it was written for Ruby-based Mustache template system, it should work for Google's C-based *ctemplate* as well as Erlang-based *et*. All of them are, AFAIK, based on the idea of ctemplate.
10 " References:
11 " [Mustache](http://github.com/defunkt/mustache)
12 " [ctemplate](http://code.google.com/p/google-ctemplate/)
13 " [ctemplate doc](http://google-ctemplate.googlecode.com/svn/trunk/doc/howto.html)
14 " [et](http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html)
15 " TODO: Feedback is welcomed.
16
17
18 " Read the HTML syntax to start with
19 if version < 600
20 so <sfile>:p:h/html.vim
21 else
22 runtime! syntax/html.vim
23 unlet b:current_syntax
24 endif
25
26 if version < 600
27 syntax clear
28 elseif exists("b:current_syntax")
29 finish
30 endif
31
32 " Standard HiLink will not work with included syntax files
33 if version < 508
34 command! -nargs=+ HtmlHiLink hi link <args>
35 else
36 command! -nargs=+ HtmlHiLink hi def link <args>
37 endif
38
39 syntax match mustacheError '}}}\?'
40 syntax match mustacheInsideError '{{[{#^<>=!\/]\?' containedin=@mustacheInside
41 syntax region mustacheVariable matchgroup=mustacheMarker start=/{{/ end=/}}/ containedin=@htmlMustacheContainer
42 syntax region mustacheVariableUnescape matchgroup=mustacheMarker start=/{{{/ end=/}}}/ containedin=@htmlMustacheContainer
43 syntax region mustacheSection matchgroup=mustacheMarker start='{{[#^/]' end=/}}/ containedin=@htmlMustacheContainer
44 syntax region mustachePartial matchgroup=mustacheMarker start=/{{[<>]/ end=/}}/
45 syntax region mustacheMarkerSet matchgroup=mustacheMarker start=/{{=/ end=/=}}/
46 syntax region mustacheComment start=/{{!/ end=/}}/ contains=Todo containedin=htmlHead
47
48
49 " Clustering
50 syntax cluster mustacheInside add=mustacheVariable,mustacheVariableUnescape,mustacheSection,mustachePartial,mustacheMarkerSet
51 syntax cluster htmlMustacheContainer add=htmlHead,htmlTitle,htmlString,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6
52
53
54 " Hilighting
55 " mustacheInside hilighted as Number, which is rarely used in html
56 " you might like change it to Function or Identifier
57 HtmlHiLink mustacheVariable Number
58 HtmlHiLink mustacheVariableUnescape Number
59 HtmlHiLink mustachePartial Number
60 HtmlHiLink mustacheSection Number
61 HtmlHiLink mustacheMarkerSet Number
62
63 HtmlHiLink mustacheComment Comment
64 HtmlHiLink mustacheMarker Identifier
65 HtmlHiLink mustacheError Error
66 HtmlHiLink mustacheInsideError Error
67
68 let b:current_syntax = "mustache"
69 delcommand HtmlHiLink