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