mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2025-12-09 06:04:46 +08:00
Handle folding in script and template/style separately
This commit is contained in:
@@ -69,23 +69,34 @@ function! GetVueFold(lnum)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Fold by indent
|
" Fold by indent
|
||||||
|
if a:lnum > 1
|
||||||
|
let prev_indent = s:IndentLevel(a:lnum - 1)
|
||||||
|
else
|
||||||
|
let prev_indent = 0
|
||||||
|
endif
|
||||||
let this_indent = s:IndentLevel(a:lnum)
|
let this_indent = s:IndentLevel(a:lnum)
|
||||||
let next_indent = s:IndentLevel(s:NextNonBlankLine(a:lnum))
|
let next_indent = s:IndentLevel(s:NextNonBlankLine(a:lnum))
|
||||||
|
|
||||||
if a:lnum > 1
|
if GetVueTag(a:lnum) == 'script'
|
||||||
let prev_indent = s:IndentLevel(a:lnum - 1)
|
" Handle closing '}'
|
||||||
|
if this_line =~ '\v^\s*},?\s*$'
|
||||||
if this_indent < prev_indent
|
return '<'.prev_indent
|
||||||
return prev_indent
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" --this
|
||||||
|
" ----next
|
||||||
|
if this_indent < next_indent
|
||||||
|
return '>'.next_indent
|
||||||
|
endif
|
||||||
|
|
||||||
|
" ----this
|
||||||
|
" --next
|
||||||
if this_indent >= next_indent
|
if this_indent >= next_indent
|
||||||
return this_indent
|
return this_indent
|
||||||
endif
|
endif
|
||||||
|
else
|
||||||
if this_indent < next_indent
|
" Template or style
|
||||||
return '>'.next_indent
|
return this_indent
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -269,8 +269,12 @@ function! s:PrevNonBlacnkNonComment(lnum)
|
|||||||
return prevlnum
|
return prevlnum
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! GetVueTag()
|
function! GetVueTag(...)
|
||||||
|
if a:0 > 0
|
||||||
|
let lnum = a:1
|
||||||
|
else
|
||||||
let lnum = getcurpos()[1]
|
let lnum = getcurpos()[1]
|
||||||
|
endif
|
||||||
let cursyns = s:SynsEOL(lnum)
|
let cursyns = s:SynsEOL(lnum)
|
||||||
let syn = get(cursyns, 0, '')
|
let syn = get(cursyns, 0, '')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user