mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-21 16:39:06 +02:00
fix(mini.animate): disable snacks.scroll
when mini.animate
is enabled
This commit is contained in:
parent
44c712aa31
commit
9b07544e89
1 changed files with 58 additions and 48 deletions
|
@ -1,54 +1,64 @@
|
||||||
-- animations
|
-- animations
|
||||||
return {
|
return {
|
||||||
"echasnovski/mini.animate",
|
-- disable snacks scroll when animate is enabled
|
||||||
recommended = true,
|
{
|
||||||
event = "VeryLazy",
|
"snacks.nvim",
|
||||||
cond = vim.g.neovide == nil,
|
opts = {
|
||||||
opts = function(_, opts)
|
scroll = { enabled = false },
|
||||||
-- don't use animate when scrolling with the mouse
|
},
|
||||||
local mouse_scrolled = false
|
},
|
||||||
for _, scroll in ipairs({ "Up", "Down" }) do
|
|
||||||
local key = "<ScrollWheel" .. scroll .. ">"
|
|
||||||
vim.keymap.set({ "", "i" }, key, function()
|
|
||||||
mouse_scrolled = true
|
|
||||||
return key
|
|
||||||
end, { expr = true })
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
-- setup animate
|
||||||
pattern = "grug-far",
|
{
|
||||||
callback = function()
|
"echasnovski/mini.animate",
|
||||||
vim.b.minianimate_disable = true
|
event = "VeryLazy",
|
||||||
end,
|
cond = vim.g.neovide == nil,
|
||||||
})
|
opts = function(_, opts)
|
||||||
|
-- don't use animate when scrolling with the mouse
|
||||||
|
local mouse_scrolled = false
|
||||||
|
for _, scroll in ipairs({ "Up", "Down" }) do
|
||||||
|
local key = "<ScrollWheel" .. scroll .. ">"
|
||||||
|
vim.keymap.set({ "", "i" }, key, function()
|
||||||
|
mouse_scrolled = true
|
||||||
|
return key
|
||||||
|
end, { expr = true })
|
||||||
|
end
|
||||||
|
|
||||||
Snacks.toggle({
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
name = "Mini Animate",
|
pattern = "grug-far",
|
||||||
get = function()
|
callback = function()
|
||||||
return not vim.g.minianimate_disable
|
vim.b.minianimate_disable = true
|
||||||
end,
|
end,
|
||||||
set = function(state)
|
})
|
||||||
vim.g.minianimate_disable = not state
|
|
||||||
end,
|
|
||||||
}):map("<leader>ua")
|
|
||||||
|
|
||||||
local animate = require("mini.animate")
|
Snacks.toggle({
|
||||||
return vim.tbl_deep_extend("force", opts, {
|
name = "Mini Animate",
|
||||||
resize = {
|
get = function()
|
||||||
timing = animate.gen_timing.linear({ duration = 50, unit = "total" }),
|
return not vim.g.minianimate_disable
|
||||||
},
|
end,
|
||||||
scroll = {
|
set = function(state)
|
||||||
timing = animate.gen_timing.linear({ duration = 150, unit = "total" }),
|
vim.g.minianimate_disable = not state
|
||||||
subscroll = animate.gen_subscroll.equal({
|
end,
|
||||||
predicate = function(total_scroll)
|
}):map("<leader>ua")
|
||||||
if mouse_scrolled then
|
|
||||||
mouse_scrolled = false
|
local animate = require("mini.animate")
|
||||||
return false
|
return vim.tbl_deep_extend("force", opts, {
|
||||||
end
|
resize = {
|
||||||
return total_scroll > 1
|
timing = animate.gen_timing.linear({ duration = 50, unit = "total" }),
|
||||||
end,
|
},
|
||||||
}),
|
scroll = {
|
||||||
},
|
timing = animate.gen_timing.linear({ duration = 150, unit = "total" }),
|
||||||
})
|
subscroll = animate.gen_subscroll.equal({
|
||||||
end,
|
predicate = function(total_scroll)
|
||||||
|
if mouse_scrolled then
|
||||||
|
mouse_scrolled = false
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return total_scroll > 1
|
||||||
|
end,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue