nvim-ufo icon indicating copy to clipboard operation
nvim-ufo copied to clipboard

zm and zr not working?

Open ziontee113 opened this issue 3 years ago • 5 comments

Neovim version (nvim -v | head -n1)

0.7

Operating system/version

Arch Linux

How to reproduce the issue

Pressing zm and zr

Expected behavior

Close / Open all folds by 1 level.

Actual behavior

Nothing happens.

Using ufo zR and zM works fine, but not zm and zr, they just do nothing.

vim.keymap.set("n", "zR", require("ufo").openAllFolds)
vim.keymap.set("n", "zM", require("ufo").closeAllFolds)

ziontee113 avatar Jul 14 '22 14:07 ziontee113

It should work as expected when folelevel is small.

foldmethod=manual should better set a large value for foldlevel. I have no idea how to maintain a my_foldlevel to make zm and zr work like small foldlevel.

kevinhwang91 avatar Jul 14 '22 14:07 kevinhwang91

Oh thanks, I just copied the sample code that sets foldlevel=99. Setting it to 1 solves the problem, I'll experiment with it further.

ziontee113 avatar Jul 14 '22 14:07 ziontee113

Actually setting foldlevel to 1 is stupid. I changed it back to 99 and use vim.o.foldlevelstart = 0. Works fine for now :)

ziontee113 avatar Jul 14 '22 14:07 ziontee113

With a small foldlevel, users should better call require('ufo').disableFold(bufnr) and require('ufo').enableFold(bufnr) by themselves.

kevinhwang91 avatar Jul 14 '22 14:07 kevinhwang91

I think having -1 foldlevelstart screws up zm and zr for some reason. If I set it to -1 zm and zr just do absolutely nothing.

ziontee113 avatar Jul 14 '22 14:07 ziontee113