Permalink
Browse files

Added vim-handlebars

  • Loading branch information...
1 parent 6fd40c0 commit a1518b136abb2b697970e12cad81664e6c812696 @arthurgeek committed Jan 10, 2012
Showing with 109 additions and 0 deletions.
  1. +3 −0 ftdetect/handlebars.vim
  2. +10 −0 ftplugin/handlebars.vim
  3. +10 −0 indent/handlebars.vim
  4. +86 −0 syntax/handlebars.vim
View
@@ -0,0 +1,3 @@
+if has("autocmd")
+ au BufNewFile,BufRead *.handlebars,*.hbs set filetype=handlebars
+endif
View
@@ -0,0 +1,10 @@
+" Taken from https://github.com/juvenn/mustache.vim/blob/master/ftplugin/mustache.vim
+
+if exists("loaded_matchit")
+ let b:match_ignorecase = 0
+
+ let b:match_words = '{:},[:],(:),'
+ \ . '\%({{\)\@<=[#^]\s*\([-0-9a-zA-Z_?!/.]\+\)\s*}}'
+ \ . ':'
+ \ . '\%({{\)\@<=/\s*\1\s*}}'
+endif
View
@@ -0,0 +1,10 @@
+" Handlebars indent
+" Taken from https://github.com/juvenn/mustache.vim/blob/master/indent/mustache.vim
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+" Use HTML formatting rules.
+runtime! indent/html.vim
View
@@ -0,0 +1,86 @@
+" Handlebars syntax
+" Language: Handlebars
+" Maintainer: Bruno Michel <brmichel@free.fr>
+" Last Change: Jun 23th, 2011
+" Version: 0.1
+" URL: https://github.com/nono/vim-handlebars
+
+
+" Read the HTML syntax to start with
+if version < 600
+ so <sfile>:p:h/html.vim
+else
+ runtime! syntax/html.vim
+ unlet b:current_syntax
+endif
+
+if version < 600
+ syntax clear
+elseif exists("b:current_syntax")
+ finish
+endif
+
+" Standard HiLink will not work with included syntax files
+if version < 508
+ command! -nargs=+ HtmlHiLink hi link <args>
+else
+ command! -nargs=+ HtmlHiLink hi def link <args>
+endif
+
+
+syn match hbsError /}}}\?/
+syn match hbsInsideError /{{[{#<>=!\/]\?/ containedin=@hbsInside
+
+syn cluster htmlHbsContainer add=htmlHead,htmlTitle,htmlString,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6
+syn region hbsInside start=/{{/ end=/}}/ keepend transparent containedin=@htmlHbsContainer
+
+syn match hbsHandlebars "{{\|}}" containedin=hbsInside
+syn match hbsUnescape "{{{\|}}}" containedin=hbsInside
+syn match hbsOperators "=\|\.\|/" containedin=hbsInside
+
+syn region hbsSection start="{{[#/]"lc=2 end=/}}/me=e-2 containedin=hbsInside
+syn region hbsPartial start=/{{[<>]/lc=2 end=/}}/me=e-2 containedin=hbsInside
+syn region hbsMarkerSet start=/{{=/lc=2 end=/=}}/me=e-2 containedin=hbsInside
+
+syn region hbsComment start=/!/ end=/}}/me=e-2 containedin=htmlHead contains=Todo
+syn region hbsQString start=/'/ skip=/\\'/ end=/'/ containedin=hbsInside
+syn region hbsDQString start=/"/ skip=/\\"/ end=/"/ containedin=hbsInside
+
+syn match hbsConditionals "\([/#]\(if\|unless\)\|else\)" containedin=hbsInside
+syn match hbsHelpers "[/#]\(with\|each\)" containedin=hbsInside
+
+
+" Define the default highlighting.
+" For version 5.7 and earlier: only when not done already
+" For version 5.8 and later: only when an item doesn't have highlighting yet
+if version >= 508 || !exists("did_lisp_syntax_inits")
+ if version < 508
+ let did_lisp_syntax_inits = 1
+ command -nargs=+ HiLink hi link <args>
+ else
+ command -nargs=+ HiLink hi def link <args>
+ endif
+
+ HtmlHiLink hbsError Error
+ HtmlHiLink hbsInsideError Error
+
+ HtmlHiLink hbsHandlebars Identifier
+ HtmlHiLink hbsUnescape Special
+ HtmlHiLink hbsOperators Operator
+
+ HtmlHiLink hbsConditionals Conditional
+ HtmlHiLink hbsHelpers Repeat
+
+ HtmlHiLink hbsSection Number
+ HtmlHiLink hbsPartial Include
+ HtmlHiLink hbsMarkerSet Number
+
+ HtmlHiLink hbsComment Comment
+ HtmlHiLink hbsQString String
+ HtmlHiLink hbsDQString String
+
+ delcommand HiLink
+endif
+
+
+let b:current_syntax = 'handlebars'

0 comments on commit a1518b1

Please sign in to comment.