neoscroll.nvim icon indicating copy to clipboard operation
neoscroll.nvim copied to clipboard

Smooth scroll with mouse wheel (`<ScrollWheelUp>`/`<ScrollWheelDown>`)

Open karb94 opened this issue 2 years ago • 4 comments

Simply binding <ScrollWheelUp>/<ScrollWheelDown> to the scroll function doesn't quite work as there's some stuttering from time to time. I need to investigate what is the issue is and see if it can be fixed.

karb94 avatar Jan 15 '22 10:01 karb94

This could be helpful https://stackoverflow.com/questions/4064651/what-is-the-best-way-to-do-smooth-scrolling-in-vim

vaibd avatar Jan 15 '22 11:01 vaibd

For now I fixed it with this


vim.keymap.set('n', '<ScrollWheelUp>', '<C-y>')
vim.keymap.set('n', '<ScrollWheelDown>', '<C-e>')
vim.keymap.set('i', '<ScrollWheelUp>', '<C-y>')
vim.keymap.set('i', '<ScrollWheelDown>', '<C-e>')
vim.keymap.set('v', '<ScrollWheelUp>', '<C-y>')
vim.keymap.set('v', '<ScrollWheelDown>', '<C-e>')

require 'neoscroll'.setup {
	mappings = { '<C-y>', '<C-e>' },
}

ignamartinoli avatar Jun 20 '22 07:06 ignamartinoli

Mapping each ScrollWheel events to <C-y>/<C-e> will make the scrolling in a constant slow speed.

A better way would be to first count the number of incoming ScrollWheel events, calculate the offset, and then scroll only once.

champignoom avatar Jan 03 '24 07:01 champignoom