Implement relative scrolloff#45
Open
danielzuncke wants to merge 3 commits into
Open
Conversation
It overwrites scrolloff if it is set: allows keeping regular scrolloff in nvim config in case the plugin is removed or relative is turned off. Update README.md with new behavior and config. Why ^^^ When using a large scrolloff (ex. 1/3 of window_height) and using split windows, the code becomes very jumpy: after even one horizontal split, every vertical cursor movement will trigger the code to move. Calculating the scrolloff based of the current selected nvim window height keeps a "stable" section of code in the center of the window.
Old ^^^ VimResized: I believe this fires if the height / width of the Neovim application changes, ex. resizing the Terminal running Neovim. BufEnter: If there are multiple windows showing the same buffer, this won't fire when switching between them. New ^^^ WinResized: After a window in the current tabpage changed width or height. WinEnter: This fires when a window is entered.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Copied from the Issue description, didn't know this gets another description:
I have implemented this and fixed a related problem in the same branch: the 2 events
VimResized,BufEnteron which a scrolloff recalculation happens should beWinResizedandWinEnter(I think those were the intended ones anyways):VimResizeddoesn't fire when resizing windows; ex. if there are multiple horizontal windows and one is made smaller verticallyC-w20-, then the recalculation isn't triggered (neitherrelative, nor safety half-of-height).BufEnterdoesn't fire when a new window is entered that shows the same underlying buffer; ex. (horizontal):split.This is fixed with:
WinResizedfires after a window resizing (which would also happen onVimResized, at least if relevant).WinEnterfires when any other window is entered, regardless of underlying buffer.Also there was a line indented with tab instead of spaces.
Closes #44