mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2025-12-07 13:14:34 +08:00
Improve code and performance
This commit is contained in:
@@ -20,11 +20,11 @@ function! s:MergeDefaultWithConfig(user)
|
||||
\ 'template': ['html'],
|
||||
\ 'style': ['css'],
|
||||
\},
|
||||
\'full_syntax': [],
|
||||
\'attribute': 0,
|
||||
\'keyword': 0,
|
||||
\'foldexpr': 0,
|
||||
\'init_indent': expand('%:e') == 'wpy',
|
||||
\'full_syntax': [],
|
||||
\'debug': 0,
|
||||
\}
|
||||
|
||||
@@ -122,18 +122,18 @@ let s:style_with_css_prefix = ['scss', 'less', 'stylus']
|
||||
" Adjust syntax name to support emmet-vim by adding css prefix
|
||||
function! vue#AlterSyntaxForEmmetVim(name, syntax)
|
||||
let name = a:name
|
||||
if count(s:style_with_css_prefix, a:syntax) == 1
|
||||
if count(s:style_with_css_prefix, a:syntax)
|
||||
let name = 'css'.toupper(name[0]).name[1:]
|
||||
endif
|
||||
return name
|
||||
endfunction
|
||||
|
||||
" Remove css prefix
|
||||
function! s:RecoverSyntax(syntax_name, syntax)
|
||||
function! s:RemoveCssPrefix(syntax_name, syntax)
|
||||
let syntax = a:syntax
|
||||
if syntax == 'css'
|
||||
let next_syntax = tolower(matchstr(a:syntax_name, '^\U\+\zs\u\U\+'))
|
||||
if count(s:style_with_css_prefix, next_syntax) == 1
|
||||
if count(s:style_with_css_prefix, next_syntax)
|
||||
let syntax = next_syntax
|
||||
endif
|
||||
endif
|
||||
@@ -143,7 +143,7 @@ endfunction
|
||||
function! s:GetBlockSyntax(lnum)
|
||||
let syntax_name = s:SyntaxAtEnd(a:lnum)
|
||||
let syntax = matchstr(syntax_name, '^\U\+')
|
||||
let syntax = s:RecoverSyntax(syntax_name, syntax)
|
||||
let syntax = s:RemoveCssPrefix(syntax_name, syntax)
|
||||
return syntax
|
||||
endfunction
|
||||
|
||||
@@ -156,8 +156,7 @@ function! vue#GetBlockSyntax(lnum)
|
||||
endfunction
|
||||
|
||||
function! GetVueSubtype()
|
||||
let lnum = line('.')
|
||||
let syntax = vue#GetBlockSyntax(lnum)
|
||||
let syntax = vue#GetBlockSyntax(line('.'))
|
||||
return syntax
|
||||
endfunction
|
||||
|
||||
@@ -169,7 +168,7 @@ endfunction
|
||||
function! vue#LoadSyntax(group, syntax)
|
||||
let group = a:group
|
||||
let syntax = a:syntax
|
||||
if count(s:full_syntax, syntax) == 1
|
||||
if count(s:full_syntax, syntax)
|
||||
call vue#LoadFullSyntax(group, syntax)
|
||||
else
|
||||
let loaded = vue#LoadDefaultSyntax(group, syntax)
|
||||
|
||||
@@ -199,11 +199,15 @@ function! GetVueIndent()
|
||||
return ind
|
||||
endfunction
|
||||
|
||||
function! s:Main()
|
||||
function! VimVuePluginIndentMain(...)
|
||||
call s:Init()
|
||||
let syntax_list = vue#GetSyntaxList(s:config_syntax)
|
||||
call s:SetIndentExpr(syntax_list)
|
||||
call s:SetVueIndent()
|
||||
endfunction
|
||||
|
||||
call s:Main()
|
||||
if exists('*timer_start')
|
||||
call timer_start(50, 'VimVuePluginIndentMain')
|
||||
else
|
||||
call VimVuePluginIndentMain()
|
||||
endif
|
||||
|
||||
@@ -41,19 +41,19 @@ let s:match_option =
|
||||
\.' contains='.s:contains
|
||||
\.' skipwhite skipempty'
|
||||
|
||||
execute 'syntax match vueObjectKey /'
|
||||
execute 'syntax match vueObjectKey display /'
|
||||
\.s:keywords_regexp
|
||||
\.'\s*:/'
|
||||
\.s:match_option
|
||||
\.' nextgroup=jsObjectValue'
|
||||
|
||||
execute 'syntax match vueObjectFuncName /'
|
||||
execute 'syntax match vueObjectFuncName display /'
|
||||
\.s:keywords_regexp
|
||||
\.'\_s*\(/'
|
||||
\.s:match_option
|
||||
\.' nextgroup=jsFuncArgs'
|
||||
|
||||
execute 'syntax match vueObjectFuncKey /'
|
||||
execute 'syntax match vueObjectFuncKey display /'
|
||||
\.s:keywords_regexp
|
||||
\.'\s*:\s*function>/'
|
||||
\.s:match_option
|
||||
@@ -67,7 +67,7 @@ let s:vue3_keywords_regexp = '\v<('
|
||||
\.join(split(s:vue3_keywords, ' '), '|')
|
||||
\.')\ze'
|
||||
|
||||
execute 'syntax match vue3Keyword /'
|
||||
execute 'syntax match vue3Keyword display /'
|
||||
\.s:vue3_keywords_regexp
|
||||
\.'\_s*\(/'
|
||||
\.s:match_option
|
||||
|
||||
@@ -136,7 +136,7 @@ function! s:HighlightVueTag()
|
||||
endfunction
|
||||
|
||||
function! s:SetSyntaxSync()
|
||||
syntax sync fromstart
|
||||
" syntax sync fromstart
|
||||
endfunction
|
||||
|
||||
function! s:SetIsKeyword()
|
||||
@@ -151,7 +151,7 @@ function! s:SetIsKeyword()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! VimVuePluginSyntaxMain(id)
|
||||
function! VimVuePluginSyntaxMain(...)
|
||||
call s:Init()
|
||||
let syntax_list = vue#GetSyntaxList(s:config_syntax)
|
||||
call s:LoadSyntaxList(syntax_list)
|
||||
@@ -161,7 +161,10 @@ function! VimVuePluginSyntaxMain(id)
|
||||
call s:HighlightVueTag()
|
||||
endfunction
|
||||
|
||||
" call timer_start(10, 'VimVuePluginSyntaxMain')
|
||||
call VimVuePluginSyntaxMain(0)
|
||||
if exists('*timer_start')
|
||||
call timer_start(1, 'VimVuePluginSyntaxMain')
|
||||
else
|
||||
call VimVuePluginSyntaxMain()
|
||||
endif
|
||||
|
||||
let b:current_syntax = 'vue'
|
||||
|
||||
Reference in New Issue
Block a user