kevinhwang91 / nvim-ufo

Not UFO in the sky, but an ultra fold in Neovim.
BSD 3-Clause "New" or "Revised" License
2.23k stars 44 forks source link

fix: Make `closeAllFolds` work the same way `zM` does #40

Closed anuvyklack closed 2 years ago

anuvyklack commented 2 years ago

By default, in Vim zM close not only top level folds, but all folds recursively. This pull request make closeAllFolds behaves the same way.

kevinhwang91 commented 2 years ago

Thanks a lot, the perf is better than previous one!

anuvyklack commented 2 years ago

I have found even better solution: silent! %foldclose! and silent! %foldopen!

So you can, for example, in setup function set:

vim.keymap.set({'n','v'}, 'zR', '<Cmd>silent! %foldopen!<CR>', { desc = 'Ufo: open all folds' })
vim.keymap.set({'n','v'}, 'zM', '<Cmd>silent! %foldclose!<CR>', { desc = 'Ufo: close all folds' })

And not bother user with it.

Or set

vim.keymap.set({'n','v'}, '<Plug>(UfoOpenAllFolds)', '<Cmd>silent! %foldopen!<CR>, { desc = 'Ufo: open all folds' })

and allow user to do in his config

vim.keymap.set('n', 'zR', '<Plug>(UfoOpenAllFolds)')
kevinhwang91 commented 2 years ago

like a charm, but I want to test them for a day.

kevinhwang91 commented 2 years ago

Thanks!