Support for simultanious scroll and centering
JulianGodd opened this issue · 3 comments
JulianGodd commented
I usually map zz after <c-b>
and <c-f>
but doing this with neoscroll causes these behaviors to happen one after another.
I was able to get the desired functionality with the following, but it's a bit hacky:
vim.keymap.set({'n', 'v'}, '<c-b>', '<cmd>lua vim.api.nvim_command("normal " .. vim.api.nvim_win_get_height(0)-5 .. "k"); require("neoscroll").zz(220)<cr>')
vim.keymap.set({'n', 'v'}, '<c-f>', '<cmd>lua vim.api.nvim_command("normal " .. vim.api.nvim_win_get_height(0)-5 .. "j"); require("neoscroll").zz(220)<cr>')
Perhaps a by default false bool on the scroll action could enable centering?
Thanks for this awesome plugin
mikkelon commented
I agree, this would be a nice option to have out of the box.
The solution by @JulianGodd did not work for me, so I solved it using the post_hook.
require('neoscroll').setup({
post_hook = function(info) if info == 'centercursor' then vim.cmd('normal! zz') end end,
})
local t = {}
t['<C-u>'] = { 'scroll', { '-vim.wo.scroll', 'true', '350', 'sine', [['centercursor']] } }
t['<C-d>'] = { 'scroll', { 'vim.wo.scroll', 'true', '350', 'sine', [['centercursor']] } }
require('neoscroll.config').set_mappings(t)
karb94 commented
Isn't a better solution to bring the cursor to the middle of the window with <S-m>
before scrolling?