declancm / cinnamon.nvim

Smooth scrolling for ANY command 🤯. A Neovim plugin written in Lua!
MIT License
363 stars 6 forks source link

Feature request: Expose post scroll callback #33

Closed simonmandlik closed 4 months ago

simonmandlik commented 5 months ago

This would help with integration with other plugins, for example hlslens.nvim.

Context: https://github.com/kevinhwang91/nvim-hlslens/issues/71#issuecomment-2179050589

declancm commented 5 months ago

Definitely! Hopefully soon I'll be doing a major refactor (switching to async delays etc) and I'll add this in

declancm commented 5 months ago

I've started refactoring here: https://github.com/declancm/cinnamon.nvim/tree/the-refactoring I have only just started the refactoring so there will be many breaking changes and its missing many features but if you call the scroll function directly (require('cinnamon').scroll) you can play around with the new callback functionality

Note: Haven't updated the README yet so you'll need to check the source for the new function args

simonmandlik commented 5 months ago

Thanks for the heads-up. I will gladly wait for when it's completely finished 🙂

Let me know if you need any help with the testing once it's done

declancm commented 4 months ago

Getting very close to completing the re-write! It would be great if you could try it out

declancm commented 4 months ago

Callback option has been merged!

simonmandlik commented 4 months ago

@declancm I have tested the rewritten version. Looks good!

Is it still possible to limit max total scroll time as in the previous version? (if options.delta * nsteps > max_scroll_time, reduce options.delta)

simonmandlik commented 4 months ago

I have also noticed that there is conflicting behavior when using with Aasim-A/scrollEOF.nvim, which I don't remember from the previous version.

declancm commented 4 months ago

I tried that plugin and it seems to be working fine, what behavior are you seeing?

simonmandlik commented 4 months ago

Here's MWE

local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

local plugins = {
    {
        "declancm/cinnamon.nvim",
        config = function()
            require("cinnamon").setup {
                keymaps = {
                    basic = true,
                    extra = false
                },
            }
        end
    },
    {
        'Aasim-A/scrollEOF.nvim',
        config = true
    }
}

require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.o.scrolloff = 10
vim.o.nu = true

Sometimes when scrolling the blank space at the bottom is preserved, sometimes it is not. This is what happens when I start at the bottom of 29-line long file and try scrolling up and down (C-u and C-d):

https://github.com/declancm/cinnamon.nvim/assets/16707112/05804508-0b53-429d-a124-fc91fa318b32

When I'm moving up/down with j/k the blank space appears again

declancm commented 4 months ago

That commit should fix the issue :)