From f8970ebdcc7d09531d638e60a4716f920c2447ce Mon Sep 17 00:00:00 2001 From: punkfairie Date: Sat, 4 Jan 2025 12:53:14 -0800 Subject: [PATCH] feat: mini.animate --- nix/neovim-overlay.nix | 1 + nvim/lua/plugins/ui/init.lua | 1 + nvim/lua/plugins/ui/mini-animate.lua | 56 ++++++++++++++++++++++++++++ nvim/lua/snacks-nvim.lua | 1 + 4 files changed, 59 insertions(+) create mode 100644 nvim/lua/plugins/ui/mini-animate.lua diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix index 99f27b9..f040de3 100644 --- a/nix/neovim-overlay.nix +++ b/nix/neovim-overlay.nix @@ -45,6 +45,7 @@ with final.pkgs.lib; let lualine-nvim noice-nvim indent-blankline-nvim + mini-animate # Editor neo-tree-nvim diff --git a/nvim/lua/plugins/ui/init.lua b/nvim/lua/plugins/ui/init.lua index 9e337de..160caf5 100644 --- a/nvim/lua/plugins/ui/init.lua +++ b/nvim/lua/plugins/ui/init.lua @@ -5,6 +5,7 @@ return { req('bufferline-nvim'), req('indent-blankline-nvim'), req('lualine-nvim'), + req('mini-animate'), req('mini-icons'), req('noice-nvim'), } diff --git a/nvim/lua/plugins/ui/mini-animate.lua b/nvim/lua/plugins/ui/mini-animate.lua new file mode 100644 index 0000000..b9dac3f --- /dev/null +++ b/nvim/lua/plugins/ui/mini-animate.lua @@ -0,0 +1,56 @@ +return { + 'mini.animate', + enabled = vim.g.neovide == nil, + event = { 'DeferredUIEnter' }, + after = function() + 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 + + vim.api.nvim_create_autocmd('FileType', { + pattern = 'grug-far', + callback = function() + vim.b.minianimate_disable = 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') + + local animate = require('mini.animate') + + local opts = { + resize = { + timing = animate.gen_timing.linear({ duration = 50, unit = 'total' }), + }, + scroll = { + timing = animate.gen_timing.linear({ duration = 50, 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, + }), + }, + } + + animate.setup(opts) + end, +} diff --git a/nvim/lua/snacks-nvim.lua b/nvim/lua/snacks-nvim.lua index 036b0e9..399fc8f 100644 --- a/nvim/lua/snacks-nvim.lua +++ b/nvim/lua/snacks-nvim.lua @@ -7,6 +7,7 @@ require('snacks').setup({ quickfile = { enabled = true }, statuscolumn = { enabled = true }, words = { enabled = true }, + scroll = { enabled = false }, }) -- Debuggers -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --