kevinhwang91 / nvim-ufo

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

Ufo seems to auto close all folds on file save and insert -> normal mode #89

Closed kandodev closed 1 year ago

kandodev commented 1 year ago

Neovim version (nvim -v | head -n1)

NVIM v0.8.0-dev-922-g42e9fe7d9

Operating system/version

linux/mac

How to reproduce the issue

Config

vim.opt.foldlevelstart = 0
vim.opt.foldnestmax = 3
vim.wo.foldcolumn = '1'
vim.wo.foldlevel = 99 
vim.wo.foldenable = true

I do not want ufo to dynamically open or close folds. I want to do that manually. However, when I enable ufo, whenever I save a file or go from insert -> normal mode, all my folds get automatically closed.

If I don't start ufo with require('ufo').setup(), everything works as expected

Expected behavior

Folds remain untouched when I don't open/close them

Actual behavior

Folds are closed automatically

kevinhwang91 commented 1 year ago

Make sure your foldlevel is large. foldlevelstart=99 may help.

kandodev commented 1 year ago

I want to start out with all folds closed though. My foldlevel is already large. Setting start to 99 fixes it but Is there no option where I can start out that way and have ufo work for me?

kevinhwang91 commented 1 year ago

https://github.com/kevinhwang91/nvim-ufo/issues/83#issuecomment-1259382127 Apply folds in ufo is always async, so need to invoke ufo API by yourself.