Rename subtype to syntax

This commit is contained in:
leafOfTree
2021-04-23 12:49:55 +08:00
parent 5067a5cc25
commit 9e55939c89
2 changed files with 31 additions and 18 deletions

View File

@@ -115,20 +115,26 @@ function! vue#GetConfig(name, default)
return s:GetConfig(a:name, a:default)
endfunction
if exists('##CursorMoved') && exists('*OnChangeVueSubtype')
if exists('##CursorMoved') && (exists('*OnChangeVueSyntax') || exists('*OnChangeVueSubtype'))
augroup vim_vue_plugin
autocmd!
autocmd CursorMoved,CursorMovedI,WinEnter *.vue,*.wpy
\ call s:CheckSubtype()
\ call s:CheckSyntax()
augroup END
let s:subtype = ''
function! s:CheckSubtype()
let subtype = GetVueSubtype()
if exists('*OnChangeVueSyntax')
let s:OnChangeListener = function('OnChangeVueSyntax')
else
let s:OnChangeListener = function('OnChangeVueSubtype')
endif
if s:subtype != subtype
call OnChangeVueSubtype(subtype)
let s:subtype = subtype
let s:syntax = ''
function! s:CheckSyntax()
let syntax = GetVueSyntax()
if s:syntax != syntax
call s:OnChangeListener(syntax)
let s:syntax = syntax
endif
endfunction
endif
@@ -203,6 +209,11 @@ function! GetVueSubtype()
return syntax
endfunction
function! GetVueSyntax()
let syntax = vue#GetBlockSyntax(line('.'))
return syntax
endfunction
function! GetVueTag(...)
let lnum = a:0 > 0 ? a:1 : line('.')
return vue#GetBlockTag(lnum)