From d5e72e0ae7c18dd41dfbaf50d99ed8963754fe37 Mon Sep 17 00:00:00 2001 From: albfan Date: Tue, 8 Dec 2015 11:19:08 +0100 Subject: [PATCH] Toggle folding on same buffer resolves #169 --- autoload/sy/fold.vim | 21 ++++++++++++++++++++- plugin/signify.vim | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/autoload/sy/fold.vim b/autoload/sy/fold.vim index 257aacd..aacb97c 100644 --- a/autoload/sy/fold.vim +++ b/autoload/sy/fold.vim @@ -38,7 +38,6 @@ function! sy#fold#do() abort return endif - tabedit % let [s:context0, s:context1] = get(g:, 'signify_fold_context', [3, 8]) let s:levels = s:get_levels(s:get_lines()) @@ -46,6 +45,13 @@ function! sy#fold#do() abort set foldtext=SignifyFoldText() set foldmethod=expr set foldlevel=0 + let g:signify_fold = 1 +endfunction + +function! sy#fold#disable() "abort + set foldmethod=manual + normal zE + let g:signify_fold = 0 endfunction " Function: s:get_lines {{{1 @@ -65,6 +71,19 @@ function! s:get_lines() abort return reverse(lines) endfunction +" Function: #fold_toggle {{{1 +function! sy#fold#toggle() abort + if get(g:, 'signify_fold') + call sy#fold#disable() + else + call sy#fold#do() + endif + + redraw! + call sy#start() +endfunction +" }}} + " Function: s:get_levels {{{1 function! s:get_levels(lines) abort let levels = {} diff --git a/plugin/signify.vim b/plugin/signify.vim index addae89..0b587e3 100644 --- a/plugin/signify.vim +++ b/plugin/signify.vim @@ -45,6 +45,7 @@ command! -nargs=0 -bar SignifyFold call sy#fold#do() command! -nargs=0 -bar SignifyRefresh call sy#util#refresh_windows() command! -nargs=0 -bar SignifyToggle call sy#toggle() command! -nargs=0 -bar SignifyToggleHighlight call sy#highlight#line_toggle() +command! -nargs=0 -bar SignifyToggleFold call sy#fold#toggle() " Init: mappings {{{1