karb94/neoscroll.nvim

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

karb94 opened this issue · 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.

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>' },
}

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.