Setting duration no longer works since the configuration change
Closed this issue · 2 comments
vividn commented
Since the recent configuration change, setting the duration as described no longer effects how long each scroll takes. My config, loaded with lazy.nvim
{
"karb94/neoscroll.nvim",
config = function()
local neoscroll = require('neoscroll').setup({
respect_scrolloff = true,
easing_function = "circular",
})
if not neoscroll then
return
end
local keymap = {
["<C-u>"] = function() neoscroll.ctrl_u({ duration = 50 }) end,
["<C-d>"] = function() neoscroll.ctrl_d({ duration = 50 }) end,
["<C-b>"] = function() neoscroll.ctrl_b({ duration = 100 }) end,
["<C-f>"] = function() neoscroll.ctrl_f({ duration = 100 }) end,
["<C-y>"] = function() neoscroll.scroll(-0.1, { move_cursor = false, duration = 20 }) end,
["<C-e>"] = function() neoscroll.scroll(0.1, { move_cursor = false, duration = 20 }) end,
["zt"] = function() neoscroll.zt({ half_win_duration = 50 }) end,
["zz"] = function() neoscroll.zz({ half_win_duration = 50 }) end,
["zb"] = function() neoscroll.zb({ half_win_duration = 50 }) end,
}
local modes = { 'n', 'v', 'x' }
for key, func in pairs(keymap) do
vim.keymap.set(modes, key, func)
end
end,
event = "BufRead"
}
changing ctrl_u for example to have a duration of 50, 500, or 5000 has no change in the behavior, which appears to always be the default value
karb94 commented
Your config is not correct. You are assigning the return value of setup()
(which doesn't have one so it returns nil
) to the local variable neoscroll
so you end up with neoscroll = nil
.
What you want to do is assign the require('neoscroll')
module to the neoscroll local variable first and then use that variable to call the setup()
function and create the mappings:
{
"karb94/neoscroll.nvim",
config = function()
local neoscroll = require('neoscroll')
neoscroll.setup({
respect_scrolloff = true,
easing_function = "circular",
})
local keymap = {
["<C-u>"] = function() neoscroll.ctrl_u({ duration = 50 }) end,
["<C-d>"] = function() neoscroll.ctrl_d({ duration = 50 }) end,
["<C-b>"] = function() neoscroll.ctrl_b({ duration = 100 }) end,
["<C-f>"] = function() neoscroll.ctrl_f({ duration = 100 }) end,
["<C-y>"] = function() neoscroll.scroll(-0.1, { move_cursor = false, duration = 20 }) end,
["<C-e>"] = function() neoscroll.scroll(0.1, { move_cursor = false, duration = 20 }) end,
["zt"] = function() neoscroll.zt({ half_win_duration = 50 }) end,
["zz"] = function() neoscroll.zz({ half_win_duration = 50 }) end,
["zb"] = function() neoscroll.zb({ half_win_duration = 50 }) end,
}
local modes = { 'n', 'v', 'x' }
for key, func in pairs(keymap) do
vim.keymap.set(modes, key, func)
end
end,
event = "BufRead"
}