Fix foldexpr on config and custom blocks

This commit is contained in:
leafOfTree
2021-04-06 13:37:00 +08:00
parent 11c04aaf7b
commit 59e9825606
2 changed files with 8 additions and 8 deletions

View File

@@ -13,8 +13,7 @@ if exists("loaded_matchit")
\ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>' \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
endif endif
" Indent correctly with template string for vim-javascript/builtin " Indent correctly with template string for vim-javascript/built-in
" indentexpr " indentexpr
let b:syng_str = '^\%(.*template\)\@!.*string\|special' let b:syng_str = '^\%(.*template\)\@!.*string\|special'
let b:syng_strcom = '^\%(.*template\)\@!.*string\|comment\|regex\|special\|doc' let b:syng_strcom = '^\%(.*template\)\@!.*string\|comment\|regex\|special\|doc'

View File

@@ -3,10 +3,11 @@
" Config {{{ " Config {{{
" "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let s:use_foldexpr = vue#GetConfig("use_foldexpr", 0) let s:config = vue#GetConfig('config', {})
let s:enable_foldexpr = s:config.foldexpr
"}}} "}}}
if !s:use_foldexpr | finish | endif if !s:enable_foldexpr | finish | endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" "
@@ -25,9 +26,8 @@ setlocal foldexpr=GetVueFold(v:lnum)
" "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let s:empty_line = '\v^\s*$' let s:empty_line = '\v^\s*$'
let s:block_end = '\v^\s*}|]|\)' let s:vue_tag_start = '\v^\s*\<\w+'
let s:vue_tag_start = '\v^\s*\<(script|style|template)' let s:vue_tag_end = '\v^\s*\<\/\w+'
let s:vue_tag_end = '\v^\s*\<\/(script|style|template)'
"}}} "}}}
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -78,6 +78,7 @@ function! GetVueFold(lnum)
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))
" Handle <script> block specially
if GetVueTag(a:lnum) == 'script' if GetVueTag(a:lnum) == 'script'
" Handle closing '}' " Handle closing '}'
if this_line =~ '\v^\s*},?\s*$' if this_line =~ '\v^\s*},?\s*$'
@@ -96,7 +97,7 @@ function! GetVueFold(lnum)
return this_indent return this_indent
endif endif
else else
" Template or style " Handle other blocks
return this_indent return this_indent
endif endif
endfunction endfunction