pseewald / vim-anyfold

Language agnostic vim plugin for folding and motion based on indentation.
MIT License
268 stars 11 forks source link

Vim's built-in za shortcut makes anyfold_toggle_key redundant #3

Closed sunaku closed 7 years ago

sunaku commented 7 years ago

Hello,

I find the mandatory mapping of anyfold_toggle_key to be unnecessary and imposing because Vim already has a za shortcut that essentially does the same thing: the only difference between them is that anyfold_toggle_key honors the g:anyfold_auto_reload setting whereas Vim's za does not. :disappointed:

If you could expose the ReloadFolds() function as a <Plug>(AnyFold-Reload-Folds) shortcut, then we could do away with the :scream_cat: mandatory anyfold_toggle_key and instead allow the user to decide :raised_hand_with_fingers_splayed: if they really want to trigger ReloadFolds() through a mapping (which is also of their choice):

nmap za <Plug>(AnyFold-Reload-Folds):normal! za<CR>

Thanks for your consideration.

pseewald commented 7 years ago

Hi,

I mostly agree. I initially planned a more sophisticated method for one-key-toggling of folds, but this should be a separate plugin and not part of AnyFold.

So yes, anyfold_toggle_key will go away and AnyFold should work with Vim's default folding commands. Exposing ReloadFolds() is unfortunately still a hack... Optimally, the foldexpr used should take care of keeping folds updated, but performance greatly suffers if this is done since reloading folds is really slow :zzz:.

So for the future, I'll consider implementing a faster fold updating, then there is no need to expose ReloadFolds(). This will take some time, so as an immediate solution I'll implement your suggestion.

Thanks for the suggestion.

pseewald commented 7 years ago

Hi again, I went for the full solution that removes the need to expose ReloadFolds(). So the good news is, anyfold_toggle_key and anyfold_auto_reload are both gone. Folds are always updated when text changes, so everything works out of the box with Vim's built-in folding commands.