kevinhwang91 / nvim-ufo

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

foldlevel-like functionality #226

Closed Axlefublr closed 2 weeks ago

Axlefublr commented 2 weeks ago

I really like the default vim's zr and zm mappings, that have the semantic of "fold less" and "fold more".

This is useful if say, I have foldlevel set to 2, and then want to expand a bunch of the folds, instead of doing :se foldlevel=3 (which makes me have to remember the foldlevel that I have set currently), I can just do zr and express my intent more directly.

As far as I know, ufo doesn't have this kind of functionality. And because it's advised to keep foldlevel at a high value, I can't use the default zr & zm mappings.

It would be convenient to keep track of ufo's "foldlevel", whenever functions like closeFoldsWith() / openFoldsExceptKinds() are used, so that ufo's own zr & zm-like functionality can be implemented.

The idea for the implementation of that that I have, is to just have a map-like table that stores the buffer numbers as keys, and the current "foldlevel" as values. Then, when the closeFoldsWith() / openFoldsExceptKinds() functions are used, they would update that foldlevel value in the buffer.

Is this kind of functionality in-scope for the project? I would love to have it :)

kevinhwang91 commented 2 weeks ago

https://github.com/kevinhwang91/nvim-ufo/issues/150