From 568f5a27627274fad4891e8307838ca55b468117 Mon Sep 17 00:00:00 2001 From: Jacob Merizian Date: Fri, 21 Jul 2017 05:07:04 -0400 Subject: [PATCH] Allows users to turn off preprocessor language parsing for better performance (#79) * removed preprocessing langs from registration I'm not sure if this will work * add back support for pre-processors adds back support for preprocessors, but keeps vim fast when not in use * completely removed support for preprocessors testing to see if completely removing preprocessor language registrations will make syntime reports more performant * added back conditional support conditional support should work now * just testing remove all preprocessor support * I think this will work * i found the actual bug some regex statements are being checked several times * quick fix for now I only apply a quick fix until I can get to the root of the problem. For this, in order to turn off the preprocessors which seem to bog down vim, just put `let g:avoid_pre_processors = 1` in the .vimrc (or neovim equivalent). * forgot endif statement * testing behavior * removed line to test behavior * Update readme.md * Update readme.md * Update vue.vim * Update vue.vim * Update readme.md --- readme.md | 4 ++++ syntax/vue.vim | 22 ++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/readme.md b/readme.md index 2de1ec7..2028f16 100644 --- a/readme.md +++ b/readme.md @@ -125,3 +125,7 @@ endfunction ``` + +### _Vim gets slows down when using this plugin_ How can I fix that? + +Add `let g:vue_disable_pre_processors=1` in your .vimrc to disable checking for prepocessors. When checking for prepocessor languages, multiple syntax highlighting checks are done, which can slow down vim. This variable prevents vim-vue from supporting **every** prepocessor language highlighting. diff --git a/syntax/vue.vim b/syntax/vue.vim index 046c338..71f82d5 100644 --- a/syntax/vue.vim +++ b/syntax/vue.vim @@ -40,16 +40,18 @@ function! s:register_language(language, tag, ...) endif endfunction -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') -call s:register_language('less', 'style') +if !exists("g:vue_disable_pre_processors") || !g:vue_disable_pre_processors + 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') + call s:register_language('less', 'style') +endif syn region vueSurroundingTag contained start=+<\(script\|style\|template\)+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent syn keyword htmlSpecialTagName contained template