mirror of
https://github.com/posva/vim-vue.git
synced 2025-12-07 01:54:27 +08:00
Allow for configurable g:vue_pre_processors
Prior to this commit, there was a single Boolean option, g:vue_disable_pre_processors, which would only activate either *every* pre-processor syntax file or none of them at all. This was a known pain point when it comes to performance. On some machines, loading all the pre-processor syntax files could slow down Vim noticeably, hence the need for such an option in the first place. However, turning all of them off means having to live with no syntax highlighting at all if one uses a pre-processor language. This commit introduces another option: g:vue_pre_processors. This is a List of names of pre-processor syntaxes, e.g. ['pug','scss']. If a user provides this option, only the named pre-processor syntax files will be loaded. This change still allows for g:vue_disable_pre_processors: If g:vue_disable_pre_processors is truthy, pre-processor syntax files aren't loaded regardless of the value of g:vue_pre_processors.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user