From f3543d8d2969fa07ffa7f76a5e0ee7d1cac341a2 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Dec 2024 09:37:47 +0100 Subject: [PATCH] refactor(snacks): move snacks specs to ui/util so that they show up in the generated docs --- lua/lazyvim/plugins/init.lua | 42 +----------------------------------- lua/lazyvim/plugins/ui.lua | 22 ++++++++++++++++++- lua/lazyvim/plugins/util.lua | 29 +++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 42 deletions(-) diff --git a/lua/lazyvim/plugins/init.lua b/lua/lazyvim/plugins/init.lua index af04f699..c06fa9bc 100644 --- a/lua/lazyvim/plugins/init.lua +++ b/lua/lazyvim/plugins/init.lua @@ -10,16 +10,6 @@ end require("lazyvim.config").init() --- Terminal Mappings -local function term_nav(dir) - ---@param self snacks.terminal - return function(self) - return self:is_floating() and "" or vim.schedule(function() - vim.cmd.wincmd(dir) - end) - end -end - return { { "folke/lazy.nvim", version = "*" }, { "LazyVim/LazyVim", priority = 10000, lazy = false, opts = {}, cond = true, version = "*" }, @@ -27,37 +17,7 @@ return { "folke/snacks.nvim", priority = 1000, lazy = false, - opts = function() - ---@type snacks.Config - return { - bigfile = { enabled = true }, - notifier = { enabled = true }, - quickfile = { enabled = true }, - statuscolumn = { enabled = false }, -- we set this in options.lua - scroll = { enabled = true }, - scope = { enabled = true }, - indent = { enabled = true }, - terminal = { - win = { - keys = { - nav_h = { "", term_nav("h"), desc = "Go to Left Window", expr = true, mode = "t" }, - nav_j = { "", term_nav("j"), desc = "Go to Lower Window", expr = true, mode = "t" }, - nav_k = { "", term_nav("k"), desc = "Go to Upper Window", expr = true, mode = "t" }, - nav_l = { "", term_nav("l"), desc = "Go to Right Window", expr = true, mode = "t" }, - }, - }, - }, - toggle = { map = LazyVim.safe_keymap_set }, - words = { enabled = true }, - } - end, - -- stylua: ignore - keys = { - { ".", function() Snacks.scratch() end, desc = "Toggle Scratch Buffer" }, - { "S", function() Snacks.scratch.select() end, desc = "Select Scratch Buffer" }, - { "n", function() Snacks.notifier.show_history() end, desc = "Notification History" }, - { "un", function() Snacks.notifier.hide() end, desc = "Dismiss All Notifications" }, - }, + opts = {}, config = function(_, opts) local notify = vim.notify require("snacks").setup(opts) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 45c2d275..127168e4 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -265,7 +265,27 @@ return { { "MunifTanjim/nui.nvim", lazy = true }, { - "folke/snacks.nvim", + "snacks.nvim", + opts = { + indent = { enabled = true }, + notifier = { enabled = true }, + scope = { enabled = true }, + scroll = { enabled = true }, + statuscolumn = { enabled = false }, -- we set this in options.lua + toggle = { map = LazyVim.safe_keymap_set }, + words = { enabled = true }, + }, + -- stylua: ignore + keys = { + { ".", function() Snacks.scratch() end, desc = "Toggle Scratch Buffer" }, + { "S", function() Snacks.scratch.select() end, desc = "Select Scratch Buffer" }, + { "n", function() Snacks.notifier.show_history() end, desc = "Notification History" }, + { "un", function() Snacks.notifier.hide() end, desc = "Dismiss All Notifications" }, + }, + }, + + { + "snacks.nvim", opts = { dashboard = { preset = { diff --git a/lua/lazyvim/plugins/util.lua b/lua/lazyvim/plugins/util.lua index 22a3e734..d52a091a 100644 --- a/lua/lazyvim/plugins/util.lua +++ b/lua/lazyvim/plugins/util.lua @@ -1,5 +1,34 @@ +-- Terminal Mappings +local function term_nav(dir) + ---@param self snacks.terminal + return function(self) + return self:is_floating() and "" or vim.schedule(function() + vim.cmd.wincmd(dir) + end) + end +end + return { + -- Snacks utils + { + "snacks.nvim", + opts = { + bigfile = { enabled = true }, + quickfile = { enabled = true }, + terminal = { + win = { + keys = { + nav_h = { "", term_nav("h"), desc = "Go to Left Window", expr = true, mode = "t" }, + nav_j = { "", term_nav("j"), desc = "Go to Lower Window", expr = true, mode = "t" }, + nav_k = { "", term_nav("k"), desc = "Go to Upper Window", expr = true, mode = "t" }, + nav_l = { "", term_nav("l"), desc = "Go to Right Window", expr = true, mode = "t" }, + }, + }, + }, + }, + }, + -- Session management. This saves your session in the background, -- keeping track of open buffers, window arrangement, and more. -- You can restore sessions when returning through the dashboard.