Closed akinsho closed 2 years ago
Hi @akinsho! Just so I'm understanding correctly, are you wanting a smooth scroll for the ~3 line jumps that the mouse scrolls to make it completely smooth?
I'll look into the <c-e>
and <c-y>
to improve them so hopefully you will be able to use them for mouse scrolling :).
This could work but it scrolls the cursor instead of scrolling the screen (always_scroll = true
should be set if you want smooth scrolling constantly):
vim.keymap.set({ 'n', 'x' }, '<ScrollWheelUp>', "<Cmd>lua Scroll('3k', 0, 0, 15)<CR>")
vim.keymap.set({ 'n', 'x' }, '<ScrollWheelDown>', "<Cmd>lua Scroll('3j', 0, 0, 15)<CR>")
@declancm so when using a trackpad, the line jumps that the mouse does can easily build up into a really long scroll which is jittery/non-smooth by default. Also, re the size of the scroll with the recently added mousescroll
option on nvim nightly as user can set this value themselves to say mousescroll=ver:1,hor:3
so it can be made even more granular.
I had tried the j
, k
mapping similar to the ones you had without the final argument or the always scroll and had noticed the behaviour with the cursor which had been off-putting. I'll try again with those options set.
I also tried the recent changes to <c-e>
and <c-y>
but still find them to be jittering at the tail end. By jittery here, I mean that it seems like the cursor line is jumping between the last two lines, so they appear to flicker. You can reproduce it by just spamming <c-y>
in a large file and wait till the cursor reaches your scroll off position, then it will start.
Just tried out your mapping and that works quite well 👍🏿, one thing that's a little unfortunate is that a small swipe upwards on my trackpad can send the scroll going for ages like dozens of events were sent and so a fairly light swipe can mean I can't stop scrolling till I hit C-C
I wonder if this can be throttled in nvim 🤔
So i think i fixed the <c-y>
and <c-e>
visual glitch when the count is 1 in 2806c5ddec9afee34acb4fd6c03e32f6cf902f66 :). I'll try looking into a way to use the mousescroll
option for vertical and horizontal scrolling with the mouse wheel
@declancm thanks for tweaking both of those. That fixes the visual glitch 👍🏿 . One thing I'm noticing using these keys though is that if sort of feels less smooth the way I have it set up. I'm not sure if it's just a matter of me configuring something but scrolling feels less smooth than other scroll motions.
I'm using
vim.keymap.set({ 'n', 'x' }, '<ScrollWheelUp>', "<Cmd>lua Scroll('<c-e>', 0, 0, 3)<CR>")
vim.keymap.set({ 'n', 'x' }, '<ScrollWheelDown>', "<Cmd>lua Scroll('<c-y>', 0, 0, 3)<CR>")
So those keymaps would just be equivalent to the following keymaps because there is no count:
vim.keymap.set({ 'n', 'x' }, '<ScrollWheelUp>', '<c-e>')
vim.keymap.set({ 'n', 'x' }, '<ScrollWheelDown>', '<c-y>')
I just did some testing and you can actually use:
vim.keymap.set({ 'n', 'x' }, '<ScrollWheelUp>', "<Cmd>lua Scroll('<ScrollWheelUp>')<CR>")
vim.keymap.set({ 'n', 'x' }, '<ScrollWheelDown>', "<Cmd>lua Scroll('<ScrollWheelDown>')<CR>")
This should respect the mousescroll
settings and do horizontal scrolling.
The plugin works by first scrolling to the correct line number and then scrolling the window. This makes it look a bit jumpy when using a heap of small movements together as it was designed for large movements. I'll try looking into making this smoother to better support wheel scrolling :)
Just tried that out and it works, except the jitter in the cursor line is back, as was the case for <C-E>
and <C-Y>
.
Hi @akinsho !
Could you please try the feature branch of this plugin? I have implemented smooth scrolling for the scroll wheel without the jitter in these commits: 204a6522d76977952184b688956a4c71267fd102 1f7d1ca8e917d2b79cd37d8acd02bf35fb6db511. Could you test if it's up to your standards before I merge with master? :)
@declancm that works really nicely thanks 👍🏿
Hi,
So I want to preface this by saying that I realise that I can remap the mouse scroll wheel commands, and I've been doing that for years with various smooth scroll plugins.
So why does this need a different solution?
<c-u>
and<c-d>
are too aggressive for a touch bad where depending on how much force you use you could end up scrolling a huge amount which was unintended.<c-e>
and<c-y>
are too small and adding a count helps slightly, but currently in this plugins once you hit the top or bottom plus/minus the scroll off the cursor line begins to jitter wildly.mousescroll
option and use that to control how much scrolling happens?There might be other ways to handle this, but I wonder if a dedicated command might not give a better result. One that can be sufficiently granular for mouse scrolling? Perhaps not, I have never properly looked into this sort of thing so no idea what's possible.