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