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

cannot scroll back with pageup after upgrade nvim-0.10

Open cxwx opened this issue 1 year ago • 3 comments

after upgrade nvim 0.9.5 -> 0.10 the pagedown is working, but pageup is not working correctly

cxwx avatar May 17 '24 07:05 cxwx

Are you getting any errors? Is it just the top of the file where pageup isnt working?

declancm avatar May 17 '24 09:05 declancm

just the top of the file where pageup isnt working

yes, but top of file, but top is more than one page

cxwx avatar May 22 '24 18:05 cxwx

I have the same problem

kohane27 avatar May 24 '24 03:05 kohane27

I was having this issue as well. Realized it's not from the plugin, but my scrolloff option was set too low. To fix, set vim.opt.scrolloff to a minimum of half the window height: vim.api.nvim_win_get_height(0) / 2.

Here's an autocmd to set vim.opt_local.scrolloff on depending on how big your window is:

local set_local_scrolloff_group = vim.api.nvim_create_augroup("set_local_scrolloff", { clear = true })
vim.api.nvim_create_autocmd({ "WinResized" }, {
  group = set_local_scrolloff_group,
  desc = "Set local scrolloff based on window height",
  pattern = { "*" },
  callback = function()
    local half_win_height = math.ceil(vim.api.nvim_win_get_height(0) / 2)
    vim.opt_local.scrolloff = half_win_height
  end,
})

danielt812 avatar Jun 19 '24 02:06 danielt812

Ah found the issue. It wasn't scrolling at the top since fixed window scrolling was enabled for those keymaps.

These keymaps should fix the issue:

vim.keymap.set({ 'n', 'x' }, '<C-b>', "<Cmd>lua Scroll('<C-b>', 0, 1)<CR>")
vim.keymap.set({ 'n', 'x' }, '<C-f>', "<Cmd>lua Scroll('<C-f>', 0, 1)<CR>")
vim.keymap.set({ 'n', 'x' }, '<PageUp>', "<Cmd>lua Scroll('<C-b>', 0, 1)<CR>")
vim.keymap.set({ 'n', 'x' }, '<PageDown>', "<Cmd>lua Scroll('<C-f>', 0, 1)<CR>")

I don't like the animation so I'm going to see if there's an easy way to improve it before I push this change. Any feedback on these is greatly appreciated!

declancm avatar Jun 19 '24 06:06 declancm