karb94 / neoscroll.nvim

Smooth scrolling neovim plugin written in lua
MIT License
1.46k stars 36 forks source link

Options not working anymore #98

Closed domi413 closed 6 months ago

domi413 commented 6 months ago

Recently the options have stopped working. e.g. the following options no longer have any effect, regardless whether the flag is true or false.

stop_eof = true, -- Stop at <EOF> when scrolling downwards
respect_scrolloff = false, -- Stop scrolling when the cursor reaches the scrolloff margin of the file

But also the scrolling speed can't be changed anymore

t["<C-u>"] = { "scroll", { "-vim.wo.scroll", "true", "1000", [['sine']] } }

As per my understanding "1000" should be visibly slow, but it's just as fast as if I leave it commented out

I'm using neovim version v.0.9.5

I'm not sure if this issue is due to my configs, but if I remember correctly, the flags worked before I updated to the latest version

karb94 commented 6 months ago

Please, provide details of how you are initialising the config. If you use Lazy as your plugin manager you can use the code below as an example:

{
  "karb94/neoscroll.nvim",
  opts = {
    mappings = {'<C-u>', '<C-d>', '<C-b>', '<C-f>',
      '<C-y>', '<C-e>', 'zt', 'zz', 'zb'},
    hide_cursor = true,          -- Hide cursor while scrolling
    stop_eof = true,             -- Stop at <EOF> when scrolling downwards
    respect_scrolloff = false,   -- Stop scrolling when the cursor reaches the scrolloff margin of the file
    cursor_scrolls_alone = true, -- The cursor will keep on scrolling even if the window cannot scroll further
    easing_function = nil,       -- Default easing function
    pre_hook = nil,              -- Function to run before the scrolling animation starts
    post_hook = nil,             -- Function to run after the scrolling animation ends
    performance_mode = false,    -- Disable "Performance Mode" on all buffers.
  },
  config = function (_, opts)
    require('neoscroll').setup(opts)

    local t = {}
    -- Syntax: t[keys] = {function, {function arguments}}
    t['<C-u>'] = {'scroll', {'-vim.wo.scroll', 'true', '250'}}
    t['<C-d>'] = {'scroll', { 'vim.wo.scroll', 'true', '250'}}
    t['<C-b>'] = {'scroll', {'-vim.api.nvim_win_get_height(0)', 'true', '450'}}
    t['<C-f>'] = {'scroll', { 'vim.api.nvim_win_get_height(0)', 'true', '450'}}
    t['<C-y>'] = {'scroll', {'-0.10', 'false', '100'}}
    t['<C-e>'] = {'scroll', { '0.10', 'false', '100'}}
    t['zt']    = {'zt', {'250'}}
    t['zz']    = {'zz', {'250'}}
    t['zb']    = {'zb', {'250'}}

    require('neoscroll.config').set_mappings(t)
  end,
}
domi413 commented 6 months ago

yes, I use lazy, the following code are my current settings. I also tested it with your code and I didn't see any difference, so it shouldn't be the config file that causes the issue.

return {
    "karb94/neoscroll.nvim",
    config = function()
        require("neoscroll").setup({
            -- All these keys will be mapped to their corresponding default scrolling animation
            mappings = { "<C-u>", "<C-d>", "<C-b>", "<C-f>", "<C-y>", "<C-e>", "zt", "zz", "zb" },
            hide_cursor = true, -- Hide cursor while scrolling
            stop_eof = true, -- Stop at <EOF> when scrolling downwards
            respect_scrolloff = false, -- Stop scrolling when the cursor reaches the scrolloff margin of the file
            cursor_scrolls_alone = false, -- The cursor will keep on scrolling even if the window cannot scroll further
            easing_function = nil, -- Default easing function
            pre_hook = nil, -- Function to run before the scrolling animation starts
            post_hook = nil, -- Function to run after the scrolling animation ends
            performance_mode = false, -- Disable "Performance Mode" on all buffers.
        })
        local t = {}
        -- Syntax: t[keys] = {function, {function arguments}}
        t["<C-u>"] = { "scroll", { "-vim.wo.scroll", "true", "150", [['sine']] } }
        t["<C-d>"] = { "scroll", { "vim.wo.scroll", "true", "150", [['sine']] } }
        t["<C-b>"] = { "scroll", { "-vim.api.nvim_win_get_height(0)", "true", "250", [['circular']] } }
        t["<C-f>"] = { "scroll", { "vim.api.nvim_win_get_height(0)", "true", "250", [['circular']] } }
        t["<C-y>"] = { "scroll", { "-0.10", "false", "100", nil } }
        t["<C-e>"] = { "scroll", { "0.10", "false", "100", nil } }
        t["zt"] = { "zt", { "300" } }
        t["zz"] = { "zz", { "300" } }
        t["zb"] = { "zb", { "300" } }

        require("neoscroll.config").set_mappings(t)
    end,
}
karb94 commented 6 months ago

Both configs work fine for me. What is the output of :verbose map <C-u>?

domi413 commented 6 months ago

Here's the output:

x  <C-U>       * <Cmd>lua require('neoscroll').scroll(-vim.wo.scroll, true, 250)<CR>                                 
        Last set from Lua
n  <C-U>       * <Cmd>lua require('neoscroll').scroll(-vim.wo.scroll, true, 250)<CR>
        Last set from Lua

The value should be 50, so there must be something that overwrites the value?

karb94 commented 6 months ago

Do you get the same if you set mappings=nil? Are you sure you haven't defined Neoscroll somewhere else? If you remove this config is Neoscroll still getting loaded by any chance?

domi413 commented 6 months ago

I just disabled most other plugins and now if i run :verbose map <C-u> it returns 50. So it must be overwritten in another plugin. I think i should now be able to solve the issue by myself and thanks for the quick reply, I appreciate it