mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2026-02-25 11:07:31 +08:00
chore: improve code format and logic
This commit is contained in:
@@ -7,9 +7,15 @@
|
|||||||
" CREDITS: Inspired by mxw/vim-jsx.
|
" CREDITS: Inspired by mxw/vim-jsx.
|
||||||
"
|
"
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
if exists("b:did_vue_indent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
se sw=2 ts=2
|
se sw=2 ts=2
|
||||||
|
|
||||||
let s:name = 'vim-vue-plugin'
|
let s:name = 'vim-vue-plugin'
|
||||||
|
let s:vue_tag = '\v\<\/?(template|script|style)'
|
||||||
|
let s:vue_end_tag = '\v\<\/?(script|style)'
|
||||||
|
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
|
||||||
@@ -34,10 +40,6 @@ setlocal indentkeys=0{,0},0),0],0\,,!^F,o,O,e
|
|||||||
" XML indentkeys
|
" XML indentkeys
|
||||||
setlocal indentkeys+=*<Return>,<>>,<<>,/
|
setlocal indentkeys+=*<Return>,<>>,<<>,/
|
||||||
|
|
||||||
let s:vue_tag = '\v\<\/?(template|script|style)'
|
|
||||||
let s:vue_tag_no_indent = '\v\<\/?(script|style)'
|
|
||||||
let s:end_tag = '^\s*\/\?>\s*'
|
|
||||||
|
|
||||||
setlocal indentexpr=GetVueIndent()
|
setlocal indentexpr=GetVueIndent()
|
||||||
|
|
||||||
function! SynsEOL(lnum)
|
function! SynsEOL(lnum)
|
||||||
@@ -75,6 +77,7 @@ function! GetVueIndent()
|
|||||||
if SynsPug(prevsyns)
|
if SynsPug(prevsyns)
|
||||||
call s:LogMsg('syntax: pug')
|
call s:LogMsg('syntax: pug')
|
||||||
let ind = GetPugIndent()
|
let ind = GetPugIndent()
|
||||||
|
|
||||||
elseif SynsHTML(prevsyns)
|
elseif SynsHTML(prevsyns)
|
||||||
call s:LogMsg('syntax: html')
|
call s:LogMsg('syntax: html')
|
||||||
let ind = XmlIndentGet(v:lnum, 0)
|
let ind = XmlIndentGet(v:lnum, 0)
|
||||||
@@ -109,11 +112,9 @@ function! GetVueIndent()
|
|||||||
call s:LogMsg('add initial indent')
|
call s:LogMsg('add initial indent')
|
||||||
let ind = &sw
|
let ind = &sw
|
||||||
endif
|
endif
|
||||||
else
|
elseif prevline =~? s:vue_end_tag
|
||||||
if prevline =~? s:vue_tag_no_indent
|
call s:LogMsg('prev is vue tag')
|
||||||
call s:LogMsg('prev is vue tag')
|
let ind = 0
|
||||||
let ind = 0
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
call s:LogMsg('result indent: '.ind)
|
call s:LogMsg('result indent: '.ind)
|
||||||
|
|
||||||
@@ -122,6 +123,6 @@ endfunction
|
|||||||
|
|
||||||
function! s:LogMsg(msg)
|
function! s:LogMsg(msg)
|
||||||
if g:vim_vue_plugin_debug
|
if g:vim_vue_plugin_debug
|
||||||
echom '['.s:name.'] '. a:msg
|
echom '['.s:name.'] '.a:msg
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user