Load syntax and then set syntax to fix syntax sync

This commit is contained in:
leafOfTree
2021-08-13 16:56:22 +08:00
parent 6e25aaf388
commit c248bd1488
2 changed files with 7 additions and 11 deletions

View File

@@ -45,6 +45,9 @@ syntax region VueExpression
\ transparent
\ start="{{"
\ end="}}"
" Just to avoid error when using pattern in containedin
syntax match htmlTemplateBlock /htmlTemplateBlock/
syntax region VueExpression
\ containedin=VueValue,htmlString,htmlValue,.*TemplateBlock,html.*Block
\ contains=@simpleJavascriptExpression

View File

@@ -2,12 +2,8 @@
" Maintainer: leaf <https://github.com/leafOfTree>
" Credits: Inspired by mxw/vim-jsx.
if !exists('g:main_syntax')
if exists('b:current_syntax') && b:current_syntax == 'vue'
finish
endif
" Prevent 'syntax sync' from being cleared
let g:main_syntax = 'vue'
if exists('b:current_syntax') && b:current_syntax == 'vue'
finish
endif
" <sfile> is replaced with the file name of the sourced file
@@ -41,6 +37,7 @@ function! s:GetGroupNameForHighlight(syntax)
return name
endfunction
" Return name with format '<syntax><Tagname>Block'
function! s:GetSynatxName(block, syntax)
let block = a:block
let syntax = a:syntax
@@ -209,17 +206,13 @@ function! s:PostSetting()
if exists('s:main_timer')
unlet s:main_timer
endif
if exists('g:main_syntax') && g:main_syntax == 'vue'
unlet g:main_syntax
endif
endfunction
function! VimVuePluginSyntaxMain(...)
call s:Init()
call s:SetBlockSyntax(s:config_syntax)
let syntax_list = vue#GetSyntaxList(s:config_syntax)
call s:LoadSyntaxList(syntax_list)
call s:SetBlockSyntax(s:config_syntax)
call s:SetExtraSyntax()
call s:PostSetting()
endfunction