diff --git a/syntax/vue.vim b/syntax/vue.vim index 3d3d514..4946b9d 100644 --- a/syntax/vue.vim +++ b/syntax/vue.vim @@ -42,17 +42,32 @@ function! s:register_language(language, tag, ...) endif endfunction +let s:language_config = { + \ 'less': ['less', 'style'], + \ 'pug': ['pug', 'template', s:attr('lang', '\%(pug\|jade\)')], + \ 'slm': ['slm', 'template'], + \ 'handlebars': ['handlebars', 'template'], + \ 'haml': ['haml', 'template'], + \ 'typescript': ['typescript', 'script', '\%(lang=\("\|''\)[^\1]*\(ts\|typescript\)[^\1]*\1\|ts\)'], + \ 'coffee': ['coffee', 'script'], + \ 'stylus': ['stylus', 'style'], + \ 'sass': ['sass', 'style'], + \ 'scss': ['scss', 'style'], + \ } + + if !exists("g:vue_disable_pre_processors") || !g:vue_disable_pre_processors - call s:register_language('less', 'style') - call s:register_language('pug', 'template', s:attr('lang', '\%(pug\|jade\)')) - call s:register_language('slm', 'template') - call s:register_language('handlebars', 'template') - call s:register_language('haml', 'template') - call s:register_language('typescript', 'script', '\%(lang=\("\|''\)[^\1]*\(ts\|typescript\)[^\1]*\1\|ts\)') - call s:register_language('coffee', 'script') - call s:register_language('stylus', 'style') - call s:register_language('sass', 'style') - call s:register_language('scss', 'style') + if exists("g:vue_pre_processors") + let pre_processors = g:vue_pre_processors + else + let pre_processors = keys(s:language_config) + endif + + for language in pre_processors + if has_key(s:language_config, language) + call call("s:register_language", get(s:language_config, language)) + endif + endfor endif syn region vueSurroundingTag contained start=+<\(script\|style\|template\)+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent