karb94 / neoscroll.nvim

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

[Feature Request]: Merge Default Keymap Settings with User Overrides #112

Closed Drew-Daniels closed 2 months ago

Drew-Daniels commented 2 months ago

It looks like when we provide custom keymaps to neoscroll in the setup function, all of the default settings are lost, whereas I would expect that all defaults would persist unless explicitly overridden.

I think it would be a nice feature if we could just provide overrides where desired and keep everything else in the default keymap settings as is.

For instance, I don't want to see smooth scrolling for these keymaps (zt, zz, zb), but I do want to see smoothed scrolling for these keymaps (<C-u>, <C-d>, <C-b>, <C-f>, <C-y>, <C-e>)

require("neoscroll").setup({
  easing_function = "quadratic",
  mappings = {
    ["zt"] = "zt",
    ["zz"] = "zz",
    ["zb"] = "zb",
  },
})

Here is what I'm currently seeing when providing a subset of overrides (all defaults are lost and I do not see smooth scrolling for the keybinds I did not explicitly override):

https://github.com/user-attachments/assets/0a0d6fd6-613f-4e50-857e-b0d646637bd4

Here is what I see when providing no overrides (defaults are persisted and I see smooth scrolling):

https://github.com/user-attachments/assets/b0683f65-af71-47bf-b59e-d513aa887eec

karb94 commented 2 months ago

Have you even read the README or the docs (:help neoscroll-setup()) before posting? I put time an effort writing them and they both literally tell you how to do that.

Quoting from the README:

You can map a smaller set of default mappings:

require('neoscroll').setup({ mappings = {'<C-u>', '<C-d>', '<C-b>', '<C-f>'} })

Quoting from the docs:

Example disabling <C-y> and <C-e> default mappings:

require('neoscroll').setup({
 mappings = {'<C-u>', '<C-d>', '<C-b>', '<C-f>', 'zt', 'zz', 'zb'}
})

mappings ( type: table, default: {'<C-u>', '<C-d>', '<C-b>', '<C-f>', '<C-y>', '<C-e>', 'zt', 'zz', 'zb'} ) All the keys defined in this option will be mapped to their corresponding default scrolling animation. To no map any key pass an empty table ({}).

So for your particular case just do:

require("neoscroll").setup({
  easing_function = "quadratic",
  mappings = {'<C-u>', '<C-d>', '<C-b>', '<C-f>', '<C-y>', '<C-e>'},
})

Your current config doesn't work because you are not passing a list but a table with keys and values to mappings.

Drew-Daniels commented 2 months ago

Apologies - that was my mistake for not reading :help neoscroll-setup() first. I had read the README but I guess the API was just a little confusing to me. Makes sense now. Appreciate the help