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

zm & za fold all code #161

Closed UNIONDONG closed 7 months ago

UNIONDONG commented 9 months ago

Neovim version (nvim -v | head -n1)

NVIM v0.10.0-dev

Operating system/version

ubuntu 5.10.16.3

How to reproduce the issue

za & zm fold all code ,why?

config :

image

Expected behavior

image

Actual behavior

normal work,only code if while and so on ...

kevinhwang91 commented 9 months ago

Are you still using neovim?

yoplat commented 9 months ago

It happens to me too but only on the first keypress, afterwards it behaves correctly. (I've remapped zr and zm as in the readme example)

kevinhwang91 commented 7 months ago

stale

mehalter commented 5 months ago

I also get this as well. Looking at the recommended mappings:

vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
vim.keymap.set('n', 'zr', require('ufo').openFoldsExceptKinds)
vim.keymap.set('n', 'zm', require('ufo').closeFoldsWith) -- closeAllFolds == closeFoldsWith(0)

It seems that the recommended keybindings for zR/zM and zr/zm just do the same things:

zR -> openAllFolds() -> openFoldsExceptKinds() zR -> openFoldsExceptKinds()

zM -> closeAllFolds() -> closeFoldsWith(0) zm -> closeFoldsWith() -> closeFoldsWith(0) (when just pressing zm without a number, vim.v.count = 0)

This leads to the behavior where zr == zR and zm == zM so there actually are no "fold more" or "fold less" operations, they are just doing the same behavvior as the "open all folds" and "close all folds".

Could this be reopened until the functions get fixed? zm and zr should essentially increment and decrement foldlevel as you press them rather than always closing/opening all folds.

If you would rather me open a new issue then I can do that as well. Thanks for all your work on this project!

jimrybarski commented 5 months ago

I was having this same issue, though it was just caused by not setting a provider. The config at the top had its provider commented out, maybe that was the issue?

require('ufo').setup({
    provider_selector = function(bufnr, filetype, buftype)
        return {'treesitter', 'indent'}
    end
})