mirror of
https://github.com/posva/vim-vue.git
synced 2025-12-07 18:14:26 +08:00
Merge pull request #133 from igemnace/feature/configurable-preprocessor
Allow granular control over loading pre-processor syntax files
This commit is contained in:
11
readme.md
11
readme.md
@@ -113,5 +113,14 @@ endfunction
|
|||||||
</details>
|
</details>
|
||||||
|
|
||||||
### _Vim slows down when using this plugin_ How can I fix that?
|
### _Vim slows down when using this plugin_ How can I fix that?
|
||||||
|
When checking for pre-processor languages, multiple syntax highlighting checks are done, which can slow down vim. You can trim down which pre-processors to use by setting `g:vue_pre_processors` to a whitelist of languages to support:
|
||||||
|
|
||||||
Add `let g:vue_disable_pre_processors=1` in your .vimrc to disable checking for prepocessors. When checking for preprocessor languages, multiple syntax highlighting checks are done, which can slow down vim. This variable prevents vim-vue from supporting **every** pre-processor language highlighting.
|
```vim
|
||||||
|
let g:vue_pre_processors = ['pug', 'scss']
|
||||||
|
```
|
||||||
|
|
||||||
|
Or alternatively, disable pre-processor languages altogether:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
let g:vue_disable_pre_processors = 1
|
||||||
|
```
|
||||||
|
|||||||
@@ -42,17 +42,35 @@ function! s:register_language(language, tag, ...)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
let s:language_config = [
|
||||||
|
\ {'lang': 'less', 'args': ['less', 'style']},
|
||||||
|
\ {'lang': 'pug', 'args': ['pug', 'template', s:attr('lang', '\%(pug\|jade\)')]},
|
||||||
|
\ {'lang': 'slm', 'args': ['slm', 'template']},
|
||||||
|
\ {'lang': 'handlebars', 'args': ['handlebars', 'template']},
|
||||||
|
\ {'lang': 'haml', 'args': ['haml', 'template']},
|
||||||
|
\ {'lang': 'typescript', 'args': ['typescript', 'script', '\%(lang=\("\|''\)[^\1]*\(ts\|typescript\)[^\1]*\1\|ts\)']},
|
||||||
|
\ {'lang': 'coffee', 'args': ['coffee', 'script']},
|
||||||
|
\ {'lang': 'stylus', 'args': ['stylus', 'style']},
|
||||||
|
\ {'lang': 'sass', 'args': ['sass', 'style']},
|
||||||
|
\ {'lang': 'scss', 'args': ['scss', 'style']},
|
||||||
|
\ ]
|
||||||
|
let s:language_dict = {}
|
||||||
|
for item in s:language_config
|
||||||
|
let s:language_dict[item.lang] = item.args
|
||||||
|
endfor
|
||||||
|
|
||||||
if !exists("g:vue_disable_pre_processors") || !g:vue_disable_pre_processors
|
if !exists("g:vue_disable_pre_processors") || !g:vue_disable_pre_processors
|
||||||
call s:register_language('less', 'style')
|
if exists("g:vue_pre_processors")
|
||||||
call s:register_language('pug', 'template', s:attr('lang', '\%(pug\|jade\)'))
|
let pre_processors = g:vue_pre_processors
|
||||||
call s:register_language('slm', 'template')
|
else
|
||||||
call s:register_language('handlebars', 'template')
|
let pre_processors = map(copy(s:language_config), {k, v -> v.lang})
|
||||||
call s:register_language('haml', 'template')
|
endif
|
||||||
call s:register_language('typescript', 'script', '\%(lang=\("\|''\)[^\1]*\(ts\|typescript\)[^\1]*\1\|ts\)')
|
|
||||||
call s:register_language('coffee', 'script')
|
for language in pre_processors
|
||||||
call s:register_language('stylus', 'style')
|
if has_key(s:language_dict, language)
|
||||||
call s:register_language('sass', 'style')
|
call call("s:register_language", get(s:language_dict, language))
|
||||||
call s:register_language('scss', 'style')
|
endif
|
||||||
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
syn region vueSurroundingTag contained start=+<\(script\|style\|template\)+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent
|
syn region vueSurroundingTag contained start=+<\(script\|style\|template\)+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent
|
||||||
|
|||||||
Reference in New Issue
Block a user