Giter Club home page Giter Club logo

Comments (3)

kiryph avatar kiryph commented on June 23, 2024

I could resolve this with your plugin as well.

nnoremap <silent><expr> zo foldclosed('.')==-1?
			\ ':execute "normal \<Plug>(fold-cycle-open)"<CR>':
			\ 'zo'

My remaining question is: how can I disable the periodic boundary condition, i.e. if everything is open, simply keep it this way?

P.S: And I have defined a similar command for zc:

nnoremap <silent><expr> zc foldclosed('.')==-1?
			\ ':execute "normal \<Plug>(fold-cycle-close)"<CR>':
			\ 'zc'

from vim-fold-cycle.

kiryph avatar kiryph commented on June 23, 2024

Adding to your plugin the variable g:fold_cycle_enable_cycling

❯ git diff
diff --git a/autoload/fold_cycle.vim b/autoload/fold_cycle.vim
index df182ef..a975f78 100644
--- a/autoload/fold_cycle.vim
+++ b/autoload/fold_cycle.vim
@@ -330,7 +330,7 @@ function! fold_cycle#open() abort "{{{3
         call s:d_msg("opening fold :1")
         foldopen
         return
-    elseif s:max_closed_fold_level == s:fold_level
+    elseif s:max_closed_fold_level == s:fold_level && g:fold_cycle_enable_cycling
         call s:d_msg("closing all folds")
         call s:branch_close_all()
         return
@@ -358,11 +358,11 @@ function! fold_cycle#close() abort "{{{3
         return
     endif
 
-    if s:folded
+    if s:folded && g:fold_cycle_enable_cycling
         call s:d_msg("opening all folds: is folded")
             call s:open_branch()
         return
-    elseif s:max_open_fold_level == 0
+    elseif s:max_open_fold_level == 0 && g:fold_cycle_enable_cycling
         call s:d_msg("opening all folds: s:max_open_fold_level = 0")
             call s:open_branch()
         return
diff --git a/plugin/fold_cycle.vim b/plugin/fold_cycle.vim
index 2dcac4d..215c1ab 100644
--- a/plugin/fold_cycle.vim
+++ b/plugin/fold_cycle.vim
@@ -19,6 +19,7 @@ endif
 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 let g:fold_debug = get(g:, 'fold_cycle_debug', 0)
 let g:fold_cycle_default_mapping = get(g:, 'fold_cycle_default_mapping', 1)
+let g:fold_cycle_enable_cycling = get(g:, 'fold_cycle_enable_cycling', 1)
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""}}}
 
 " MAPPINGS {{{

and setting its value to zero in my vimrc

" Advanced Recursive/Iterative Folding Commands zo,zc,zO,zC
" Note: use `za` for built-in`zc`
nnoremap <silent><expr> zO foldclosed('.')==-1?
			\ 'zczO':
			\ 'zv'
nnoremap <silent><expr> zC foldclosed('.')==-1?
			\ ':<C-u>call fold_cycle#close_all()<CR>':
			\ 'zC'
nnoremap <silent><expr> zo foldclosed('.')==-1?
			\ ':<C-u>let g:fold_cycle_enable_cycling=0<bar>call fold_cycle#open()<bar>let g:fold_cycle_enable_cycling=1 <CR>':
			\ 'zo'
nnoremap <silent><expr> zc foldclosed('.')==-1?
			\ ':<C-u>call fold_cycle#close()<CR>':
			\ 'zc'

Now all the mappings work as I wanted.

from vim-fold-cycle.

arecarn avatar arecarn commented on June 23, 2024

I don't quite understand this at first glance. I'll leave this open as a reminder to take a look at it in the future

from vim-fold-cycle.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.