mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2026-11-03 02:47:36 +08:00
Sync syntax from start
Syncing by block start patterns didn't restore states inside the block, so syntax computed before a line was displayed, e.g. by GetVueTag() or indent after jumping in a file, missed regions like a multi-line css rule. This replaces the one-line block fix in the previous commit. Parsing from start takes ~190ms once for jumping to the end of a 6500-line file, and states are cached after that.
This commit is contained in:
1 file changed
+3
-6
+3
-6
@@ -124,12 +124,6 @@ function! s:SetSyntax(block, syntax, has_lang)
|
|||||||
\.' end=+'.end.'+'
|
\.' end=+'.end.'+'
|
||||||
\.' keepend contains='.syntax_group.', vueTag'
|
\.' keepend contains='.syntax_group.', vueTag'
|
||||||
|
|
||||||
" Don't sync to a block ending on the same line, like
|
|
||||||
" <style>p { color: red; }</style>
|
|
||||||
let sync_start = start.'\(.*'.end_tag.'\)\@!'
|
|
||||||
execute 'syntax sync match vueSync groupthere '.name.' +'.sync_start.'+'
|
|
||||||
execute 'syntax sync match vueSync groupthere NONE +'.end.'+'
|
|
||||||
|
|
||||||
" Block like <script src="...">...</script>
|
" Block like <script src="...">...</script>
|
||||||
let oneline = start.'.*'.end_tag
|
let oneline = start.'.*'.end_tag
|
||||||
execute 'syntax match '.name.' fold '
|
execute 'syntax match '.name.' fold '
|
||||||
@@ -138,7 +132,10 @@ function! s:SetSyntax(block, syntax, has_lang)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:SetBlockSyntax(config_syntax)
|
function! s:SetBlockSyntax(config_syntax)
|
||||||
|
" Parse from start, as syncing by block start doesn't restore states inside
|
||||||
|
" the block like a multi-line css rule
|
||||||
syntax sync clear
|
syntax sync clear
|
||||||
|
syntax sync fromstart
|
||||||
|
|
||||||
for [block, syntax] in items(a:config_syntax)
|
for [block, syntax] in items(a:config_syntax)
|
||||||
let type = type(syntax)
|
let type = type(syntax)
|
||||||
|
|||||||
Reference in new issue
Block a user