mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2025-12-08 21:54:46 +08:00
chore: clean code
This commit is contained in:
@@ -10,11 +10,21 @@
|
||||
if exists("b:did_vue_indent")
|
||||
finish
|
||||
endif
|
||||
|
||||
se sw=2 ts=2
|
||||
|
||||
let s:name = 'vim-vue-plugin'
|
||||
|
||||
" let <template> be handled by HTML indent
|
||||
let s:debug = exists("g:vim_vue_plugin_use_pug")
|
||||
\ && g:vim_vue_plugin_debug == 1
|
||||
let s:use_pug = exists("g:vim_vue_plugin_use_pug")
|
||||
\ && g:vim_vue_plugin_use_pug == 1
|
||||
let s:use_sass = exists("g:vim_vue_plugin_use_sass")
|
||||
\ && g:vim_vue_plugin_use_sass == 1
|
||||
let s:has_init_indent = exists("g:vim_vue_plugin_has_init_indent")
|
||||
\ && g:vim_vue_plugin_has_init_indent == 1
|
||||
|
||||
" Let <template> be handled by HTML indent
|
||||
let s:vue_tag = '\v^\<(script|style)'
|
||||
let s:vue_end_tag = '\v\<\/(template|script|style)'
|
||||
let s:end_tag = '^\s*\/\?>\s*'
|
||||
@@ -22,19 +32,19 @@ let s:end_tag = '^\s*\/\?>\s*'
|
||||
" Save the current JavaScript indentexpr.
|
||||
let b:vue_js_indentexpr = &indentexpr
|
||||
|
||||
" load xml indent method
|
||||
" Load xml indent method
|
||||
unlet! b:did_indent
|
||||
runtime! indent/xml.vim
|
||||
|
||||
" load css indent method
|
||||
" Load css indent method
|
||||
unlet! b:did_indent
|
||||
runtime! indent/css.vim
|
||||
|
||||
" load pug indent method
|
||||
" Load pug indent method
|
||||
unlet! b:did_indent
|
||||
runtime! indent/pug.vim
|
||||
|
||||
" load sass indent method
|
||||
" Load sass indent method
|
||||
unlet! b:did_indent
|
||||
runtime! indent/sass.vim
|
||||
|
||||
@@ -66,7 +76,6 @@ endfunction
|
||||
|
||||
function! SynsSASS(syns)
|
||||
let first_syn = get(a:syns, 0)
|
||||
echom first_syn
|
||||
return first_syn =~? '\v^(vueStyleSASS)'
|
||||
endfunction
|
||||
|
||||
@@ -120,8 +129,7 @@ function! GetVueIndent()
|
||||
if curline =~? s:vue_tag || curline =~? s:vue_end_tag
|
||||
call s:LogMsg('current is vue tag')
|
||||
let ind = 0
|
||||
elseif (exists("g:vim_vue_plugin_has_init_indent")
|
||||
\ && g:vim_vue_plugin_has_init_indent == 1)
|
||||
elseif s:has_init_indent
|
||||
if SynsVueScope(cursyns) && ind == 0
|
||||
call s:LogMsg('add initial indent')
|
||||
let ind = &sw
|
||||
@@ -136,7 +144,7 @@ function! GetVueIndent()
|
||||
endfunction
|
||||
|
||||
function! s:LogMsg(msg)
|
||||
if g:vim_vue_plugin_debug
|
||||
if s:debug
|
||||
echom '['.s:name.'] '.a:msg
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@@ -11,6 +11,15 @@ if exists("b:current_syntax") && b:current_syntax == 'vue'
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:load_full_syntax = exists("g:vim_vue_plugin_load_full_syntax")
|
||||
\ && g:vim_vue_plugin_load_full_syntax == 1
|
||||
let s:use_pug = exists("g:vim_vue_plugin_use_pug")
|
||||
\ && g:vim_vue_plugin_use_pug == 1
|
||||
let s:use_less = exists("g:vim_vue_plugin_use_less")
|
||||
\ && g:vim_vue_plugin_use_less == 1
|
||||
let s:use_sass = exists("g:vim_vue_plugin_use_sass")
|
||||
\ && g:vim_vue_plugin_use_sass == 1
|
||||
|
||||
function! s:LoadDefaultSyntax(group, type)
|
||||
unlet! b:current_syntax
|
||||
exec 'syn include '.a:group.' $VIMRUNTIME/syntax/'.a:type.'.vim'
|
||||
@@ -25,8 +34,7 @@ endfunction
|
||||
|
||||
|
||||
" Load syntax/*.vim to syntax group
|
||||
if exists("g:vim_vue_plugin_load_full_syntax")
|
||||
\ && g:vim_vue_plugin_load_full_syntax == 1
|
||||
if s:load_full_syntax
|
||||
call s:LoadFullSyntax('@HTMLSyntax', 'html')
|
||||
call s:LoadFullSyntax('@CSSSyntax', 'css')
|
||||
|
||||
@@ -44,25 +52,21 @@ else
|
||||
endif
|
||||
|
||||
" If pug is enabled, load vim-pug syntax
|
||||
if exists("g:vim_vue_plugin_use_pug")
|
||||
\ && g:vim_vue_plugin_use_pug == 1
|
||||
if s:use_pug
|
||||
call s:LoadFullSyntax('@PugSyntax', 'pug')
|
||||
endif
|
||||
|
||||
" If less is enabled, load less syntax
|
||||
if exists("g:vim_vue_plugin_use_less")
|
||||
\ && g:vim_vue_plugin_use_less == 1
|
||||
if s:use_less
|
||||
call s:LoadFullSyntax('@LessSyntax', 'less')
|
||||
syn clear cssDefinition
|
||||
syn region lessDefinition matchgroup=cssBraces contains=@LessSyntax
|
||||
\ start="{"
|
||||
\ end="}"
|
||||
|
||||
endif
|
||||
|
||||
" If sass is enabled, load sass syntax
|
||||
if exists("g:vim_vue_plugin_use_sass")
|
||||
\ && g:vim_vue_plugin_use_sass == 1
|
||||
if s:use_sass
|
||||
call s:LoadFullSyntax('@SassSyntax', 'sass')
|
||||
syn clear cssDefinition
|
||||
syn region sassDefinition matchgroup=cssBraces contains=@SassSyntax
|
||||
|
||||
Reference in New Issue
Block a user