From a653cbc7da73bf637ab9f8d8a5d278c7eb6d1012 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Dec 2024 07:02:12 +0100 Subject: [PATCH] fix(mini.animate): disable `snacks.scroll` when `mini.animate` is enabled --- .../plugins/extras/ui/mini-animate.lua | 106 ++++++++++-------- 1 file changed, 58 insertions(+), 48 deletions(-) diff --git a/lua/lazyvim/plugins/extras/ui/mini-animate.lua b/lua/lazyvim/plugins/extras/ui/mini-animate.lua index df4587cc..bbd3e587 100644 --- a/lua/lazyvim/plugins/extras/ui/mini-animate.lua +++ b/lua/lazyvim/plugins/extras/ui/mini-animate.lua @@ -1,54 +1,64 @@ -- animations return { - "echasnovski/mini.animate", - recommended = true, - event = "VeryLazy", - 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 = "" - vim.keymap.set({ "", "i" }, key, function() - mouse_scrolled = true - return key - end, { expr = true }) - end + -- disable snacks scroll when animate is enabled + { + "snacks.nvim", + opts = { + scroll = { enabled = false }, + }, + }, - vim.api.nvim_create_autocmd("FileType", { - pattern = "grug-far", - callback = function() - vim.b.minianimate_disable = true - end, - }) + -- setup animate + { + "echasnovski/mini.animate", + event = "VeryLazy", + 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 = "" + vim.keymap.set({ "", "i" }, key, function() + mouse_scrolled = true + return key + end, { expr = true }) + end - Snacks.toggle({ - name = "Mini Animate", - get = function() - return not vim.g.minianimate_disable - end, - set = function(state) - vim.g.minianimate_disable = not state - end, - }):map("ua") + vim.api.nvim_create_autocmd("FileType", { + pattern = "grug-far", + callback = function() + vim.b.minianimate_disable = true + end, + }) - local animate = require("mini.animate") - return vim.tbl_deep_extend("force", opts, { - resize = { - timing = animate.gen_timing.linear({ duration = 50, unit = "total" }), - }, - scroll = { - timing = animate.gen_timing.linear({ duration = 150, unit = "total" }), - subscroll = animate.gen_subscroll.equal({ - predicate = function(total_scroll) - if mouse_scrolled then - mouse_scrolled = false - return false - end - return total_scroll > 1 - end, - }), - }, - }) - end, + Snacks.toggle({ + name = "Mini Animate", + get = function() + return not vim.g.minianimate_disable + end, + set = function(state) + vim.g.minianimate_disable = not state + end, + }):map("ua") + + local animate = require("mini.animate") + return vim.tbl_deep_extend("force", opts, { + resize = { + timing = animate.gen_timing.linear({ duration = 50, unit = "total" }), + }, + scroll = { + timing = animate.gen_timing.linear({ duration = 150, unit = "total" }), + subscroll = animate.gen_subscroll.equal({ + predicate = function(total_scroll) + if mouse_scrolled then + mouse_scrolled = false + return false + end + return total_scroll > 1 + end, + }), + }, + }) + end, + }, }