Skip to content

Commit

Permalink
neoscroll: update to latest commit, use new interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Jun 12, 2024
1 parent a7a7d7a commit 1c56b85
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 31 deletions.
3 changes: 1 addition & 2 deletions lua/nxvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ local modules = {
{ "edluffy/hologram.nvim", event = "VeryLazy" },
{ "lukas-reineke/indent-blankline.nvim", event = "VeryLazy", config = "plugins.indentline" },
{ "echasnovski/mini.nvim", event = "VeryLazy", config = "plugins.mini" },
-- stylua: ignore
{ "karb94/neoscroll.nvim", event = "VeryLazy", config = "plugins.neoscroll", commit = "e78657719485c5663b88e5d96ffcfb6a2fe3eec0" },
{ "karb94/neoscroll.nvim", event = "VeryLazy", config = "plugins.neoscroll" },
{ "nacro90/numb.nvim", event = "VeryLazy", config = true },
{ "windwp/nvim-autopairs", event = "VeryLazy", config = "plugins.autopairs" },
{ "NvChad/nvim-colorizer.lua", event = "VeryLazy", config = "plugins.colorizer" },
Expand Down
48 changes: 19 additions & 29 deletions lua/nxvim/plugins/neoscroll.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,30 @@ local neoscroll = require("neoscroll")
-- { == Configuration ==> =====================================================

local config = {
-- All these keys will be mapped to their corresponding default scrolling animation
mappings = {}, -- See keymaps section below
hide_cursor = true, -- Hide cursor while scrolling
stop_eof = true, -- Stop at <EOF> when scrolling downwards
use_local_scrolloff = false, -- Use the local scope of scrolloff instead of the global scope
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 = "sine", -- 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.}
easing_function = "sine", -- Default easing function.
}
-- <== }

-- { == Keymaps ==> ===========================================================

config.mappings = { "<C-u>", "<C-d>", "<C-b>", "<C-f>", "<C-y>", "<C-e>", "zt", "zz", "zb" }

-- Mapping overrides for custom easing function / animation length
local t = {}
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" } }
-- Pass "nil" to disable the easing animation (constant scrolling speed)
-- When no easing function is provided the default easing function will be used
t["<C-y>"] = { "scroll", { "-0.10", "false", "100" } }
t["<C-e>"] = { "scroll", { "0.10", "false", "100" } }
t["<C-u>"] = { "scroll", { "-vim.wo.scroll", "true", "150", "sine" } }
t["<C-d>"] = { "scroll", { "vim.wo.scroll", "true", "150", "sine" } }
-- t["<C-u>"] = { "scroll", { "-vim.wo.scroll", "true", "175", "quintic" } }
-- t["<C-d>"] = { "scroll", { "vim.wo.scroll", "true", "175", "quintic" } }
-- t['zt'] = { 'zt', { '300' } }
-- t['zz'] = { 'zz', { '300' } }
-- t['zb'] = { 'zb', { '300' } }
nx.map({
-- { "<C-d>", function() neoscroll.ctrl_d({ time = 150, easing = "quintic" }) end },
-- { "<C-u>", function() neoscroll.ctrl_u({ time = 150, easing = "quintic" }) end },
{ "<C-d>", function() neoscroll.ctrl_d({ time = 150 }) end },
{ "<C-u>", function() neoscroll.ctrl_u({ time = 150 }) end },
{ "<C-e>", function() neoscroll.ctrl_e(-0.1, { time = 100 }) end },
{ "<C-y>", function() neoscroll.ctrl_y(0.1, { time = 100 }) end },
{ "<C-b>", function() neoscroll.ctrl_b({ time = 250, easing = "circular" }) end },
{ "<C-f>", function() neoscroll.ctrl_f({ time = 250, easing = "circular" }) end },
{
"z<CR>",
function()
vim.opt.so = 12
vim.defer_fn(function() vim.opt.so = 7 end, 250)
neoscroll.zt({ half_win_duration = 200 })
end,
},
}, { mode = "" })
-- <== }

neoscroll.setup(config)
require("neoscroll.config").set_mappings(t)

0 comments on commit 1c56b85

Please sign in to comment.