Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with folding behavior improvments #161

Open
lyndhurst opened this issue Jul 20, 2021 · 0 comments
Open

Help with folding behavior improvments #161

lyndhurst opened this issue Jul 20, 2021 · 0 comments

Comments

@lyndhurst
Copy link

lyndhurst commented Jul 20, 2021

Hi, I have been tinkering with your many incsearch plugins for a while trying to make them play nice with folding, and I have a few questions, observations if you can find the time to help me improve my configuration.

Reading issue #44, I have ended up adding 'zv' after all my 'incsearch-nohl-*' mappings, and it did improve the behavior, but I was not satisfied leaving all the buffer unfolded after navigating through the search matches. I finally added zx, and it got a little better to my taste (e.g. map n <Plug>(incsearch-nohl-n)zx ), now only the matches I jump to are unfolded, but my original fold view is still lost.

This leads me to <Over>(incsearch-*) mappings. For those, adding zv, or zx does not seem to have any effect, which makes sense as, to my understanding, the cursor is not actually moving to the matches. Unfortunately, this makes these very useful (to me) mappings much less useable.

What could make incsearch behave the way I would expect would be to unfold everything with a zn when starting a search, and restore original folding with zN when exiting the search, and, if the cursor moves to a folded match, add a zv to show it. This way, the <Over>* mappings will be useable, the folding restored, and the chosen match visible.

Following that idea, adding a zn to the incsearch mappings is easy, e.g. map / zn<Plug>(incsearch-forward). What is much trickier is to trigger the zN and zv on pressing <Cr>. The only lead I found for that could be the autocmd part of the help file and the IncSearchLeave or IncSearchExecute triggers.

As I am not familiar with vim script beyond hacking away at the config file, I would appreciate your input as to know if what I am trying to achieve is at all possible.

Thanks for taking the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant