Closed ipsod closed 1 year ago
Using a provider of ufo, must set a large value for foldlevel, this is the limitation of foldmethod=manual. A small value may close fold automatically if the fold ranges updated.
https://github.com/kevinhwang91/nvim-ufo/issues/7 https://github.com/kevinhwang91/nvim-ufo/issues/57 https://github.com/kevinhwang91/nvim-ufo/issues/89
Ah, I see. Sorry about that.
Is the config here supposed to restore normal functionality to zm
, zM
, zr
, and zR
? https://github.com/kevinhwang91/nvim-ufo#customize-configuration
I copied it directly, and zm
and zr
seem to have the same behavior as zM
and zR
.
zm
.zr
is the same as zM
if the kind is excluded in close_fold_kinds
.Is there a way to just increment/deincrement mock-indent-level, to simulate standard behavior?
No, foldlevel
should keep a large value. Must maintain your_foldlevel
by yourself. Need to write a script.
vim.api.nvim_create_autocmd({'WinNew', 'VimEnter'}, {
pattern = '*',
callback = function()
vim.w.my_foldlevel = 20
end
})
vim.keymap.set('n', 'zr', function()
vim.w.my_foldlevel = vim.w.my_foldlevel - 1
require('ufo').closeFoldsWith(vim.w.my_foldlevel)
end)
vim.keymap.set('n', 'zm', function()
vim.w.my_foldlevel = vim.w.my_foldlevel + 1
require('ufo').closeFoldsWith(vim.w.my_foldlevel)
end)
This seems to be working well. Thanks for the help!
vim.api.nvim_create_autocmd({'WinNew', 'VimEnter'}, {
pattern = '*',
callback = function()
vim.w.my_foldlevel = 1
end
})
vim.keymap.set('n', 'zM', function()
vim.w.my_foldlevel = 0
require('ufo').closeFoldsWith(vim.w.my_foldlevel)
end)
vim.keymap.set('n', 'zR', function()
vim.w.my_foldlevel = 5
require('ufo').closeFoldsWith(vim.w.my_foldlevel)
end)
vim.keymap.set('n', 'zr', function()
vim.w.my_foldlevel = vim.w.my_foldlevel + 1
require('ufo').closeFoldsWith(vim.w.my_foldlevel)
end)
vim.keymap.set('n', 'zm', function()
vim.w.my_foldlevel = math.max(vim.w.my_foldlevel - 1, 0)
require('ufo').closeFoldsWith(vim.w.my_foldlevel)
end)
Neovim version (nvim -v | head -n1)
NVIM v0.9.0-dev
Operating system/version
linux mint 21
How to reproduce the issue
create text file with multiple levels of folds:
fold to hide
sub
, but show row (set foldlevel=1
, I think)insert or delete a blank newline between the two
row
folds. Both inserting and deleting cause it.editor will now automatically (and undesirably) fold all the way, and hide
row
sExpected behavior
fold level should not change because of modification of text
Actual behavior
The text you're editing gets folded because you edited the text. Especially troublesome if it folds, then you end up deleting N folded lines instead of the single unfolded line you meant to.