pojokcodeid.nvim-lazy/lua/plugins/mini-animate.lua

46 lines
1.3 KiB
Lua
Raw Permalink Normal View History

2024-06-14 08:21:36 +07:00
if not vim.g.neovide and pcode.minianimate and true or false then
2024-06-03 09:03:01 +07:00
return {
-- animations
{
"echasnovski/mini.animate",
event = "BufRead",
2024-06-14 08:21:36 +07:00
enabled = not vim.g.neovide and pcode.minianimate and true or false,
2024-06-03 09:03:01 +07:00
opts = function()
-- don't use animate when scrolling with the mouse
local mouse_scrolled = false
2024-06-14 08:40:35 +07:00
for _, scroll in ipairs({ "Up", "Down" }) do
2024-06-03 09:03:01 +07:00
local key = "<ScrollWheel" .. scroll .. ">"
vim.keymap.set({ "", "i" }, key, function()
mouse_scrolled = true
return key
end, { expr = true })
end
2024-06-02 06:48:51 +07:00
2024-06-14 08:40:35 +07:00
local animate = require("mini.animate")
2024-06-03 09:03:01 +07:00
return {
resize = {
2024-06-14 08:40:35 +07:00
timing = animate.gen_timing.linear({ duration = 100, unit = "total" }),
2024-06-02 06:48:51 +07:00
},
2024-06-03 09:03:01 +07:00
scroll = {
2024-06-14 08:40:35 +07:00
timing = animate.gen_timing.linear({ duration = 150, unit = "total" }),
subscroll = animate.gen_subscroll.equal({
2024-06-03 09:03:01 +07:00
predicate = function(total_scroll)
if mouse_scrolled then
mouse_scrolled = false
return false
end
return total_scroll > 1
end,
2024-06-14 08:40:35 +07:00
}),
2024-06-03 09:03:01 +07:00
},
}
end,
config = function(_, opts)
require("mini.animate").setup(opts)
end,
},
}
else
return {}
end