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 \ transparent
\ start="{{" \ start="{{"
\ end="}}" \ end="}}"
" Just to avoid error when using pattern in containedin
syntax match htmlTemplateBlock /htmlTemplateBlock/
syntax region VueExpression syntax region VueExpression
\ containedin=VueValue,htmlString,htmlValue,.*TemplateBlock,html.*Block \ containedin=VueValue,htmlString,htmlValue,.*TemplateBlock,html.*Block
\ contains=@simpleJavascriptExpression \ contains=@simpleJavascriptExpression

View File

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