karb94 / neoscroll.nvim

Smooth scrolling neovim plugin written in lua
MIT License
1.46k stars 36 forks source link

Add option to make `zt` and `zb` commands move cursor to really first and last lines of the window. #28

Closed anuvyklack closed 3 years ago

anuvyklack commented 3 years ago

The title says it all.

karb94 commented 3 years ago

Are you aware that the current behaviour is the default behaviour in vanilla (neo)vim? If you want the screen to scroll until the cursor is at the first/last line of the window then you can simply set scrolloff=0.

If I'm missinterpreting the title please explain further what you want.

anuvyklack commented 3 years ago

According to :help zt it should puts current line at top of window. But currently, for me, it puts cursor at the first quarter line at window.


Edited, because misunderstood your answer at first.

anuvyklack commented 3 years ago

My scrolloff option is 0.

karb94 commented 3 years ago

According to :help zt it should puts current line at top of window

This is true as long as scrolloff=0. Try opening a file with nvim -Nu NONE and then :set scrolloff=5. You'll see that the cursor does not go to the top of the screen if you press zt (unless you are at the top of the file).

Can you please run :set scrolloff=0 and check again if zt/zb brings the cursor to the top/bottom of the window? This issue could be related to #11 somehow.

anuvyklack commented 3 years ago

Yes, it is related to #11 .

karb94 commented 3 years ago

Yes... So I tried to provide a workaround to neovim/neovim#13964 in #11 but it will break when the garbage value of local scrolloff is between 0 and half of the window size. I can't do any better than this until the neovim issue is fixed because I have no way of knowing if you set that local scrolloff=9 or is a garbage value. However, you can fix this by explicitly setting the local scrolloff in your vimrc (setlocal scrolloff=0).

anuvyklack commented 3 years ago

Thank you!