1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-04 10:40:03 +08:00
SpaceVim/autoload/SpaceVim/layers/exprfold.vim
2017-02-17 00:56:55 -05:00

45 lines
1.3 KiB
VimL

""
" @section exprfold, layer-exprfold
" @parentsection layers
" Fold code quickly according to expr.
"
" Mappings:
" >
" Key Mode Function
" ----------------------------------------------------
" ZB normal Open fold block template
" ZF normal Fold block
" ZC normal Fold block comment
" <
function! SpaceVim#layers#exprfold#plugins() abort
return [
\ ['ZSaberLv0/ZFVimFoldBlock', {'merged' : 0}],
\ ]
endfunction
function! SpaceVim#layers#exprfold#config() abort
nnoremap ZB q::call ZF_FoldBlockTemplate()<cr>
nnoremap ZF :ZFFoldBlock //<left>
function! ZF_Plugin_ZFVimFoldBlock_comment() abort
let expr='\(^\s*\/\/\)'
if &filetype ==# 'vim'
let expr.='\|\(^\s*"\)'
endif
if &filetype ==# 'c' || &filetype ==# 'cpp'
let expr.='\|\(^\s*\(\(\/\*\)\|\(\*\)\)\)'
endif
if &filetype ==# 'make'
let expr.='\|\(^\s*#\)'
endif
let disableE2vSaved = g:ZFVimFoldBlock_disableE2v
let g:ZFVimFoldBlock_disableE2v = 1
call ZF_FoldBlock('/' . expr . '//')
let g:ZFVimFoldBlock_disableE2v = disableE2vSaved
echo 'comments folded'
endfunction
nnoremap ZC :call ZF_Plugin_ZFVimFoldBlock_comment()<cr>
endfunction