harpoon
harpoon copied to clipboard
Keep viewport when switching files
What issue are you having that you need harpoon to solve? I would like to keep the viewport after switching files, currently the line is always centered on the screen. Keeping the viewport would only be necessary in the same session (after nvim reboot this is not required)
Why doesn't the current config help? No options are provided for this
What proposed api changes are you suggesting? Vim already has some options to keep the viewport with winsaveview() and winrestview(view), these could be used to save the viewport.
you want the same position the viewport was in before you left the file? is that what you are asking?
Yes, when using harpoon I like to switch between files quickly, to for instance just take a glance at some code and hop back. When this centers the line every time, this gets disorienting.
Example: I am working here
Then quickly check another file with harpoon keybind and go back with harpoon keybind and now the line is centered
I also would like that.
Okay, it seems like an okay feature. I don't really use it nor notices, so if someone would like to take a swing at saving the additional information required in the list items, context and using that on select I'd be just fine merging it in
Okay, I tried some stuff but got a lil confused, so here https://github.com/ThePrimeagen/harpoon/blob/9031087ff1b18d0a34bd664719ec66cc8be1efd8/lua/harpoon/config.lua#L194 you save where you are at in the file when leaving a buffer correct? But when testing, it seems this code is never triggered (the logger line right before doesn't show up). So is this not working? Or am I doing something wrong.
This wiki is related to the problem viewport problem @lpanebr . Might just use this for consistency everywhere https://vim.fandom.com/wiki/Avoid_scrolling_when_switch_buffers
@lars-vc Thank you! This is just AWESOME and works like magic! ❤🎉
This wiki is related to the problem viewport problem @lpanebr . Might just use this for consistency everywhere https://vim.fandom.com/wiki/Avoid_scrolling_when_switch_buffers
I am back, I'll review this today and merge/give feedback