refactor(snacks): move snacks specs to ui/util so that they show up in the generated docs

This commit is contained in:
Folke Lemaitre 2024-12-12 09:37:47 +01:00
parent 303980d267
commit ba632c500d
3 changed files with 51 additions and 42 deletions

View file

@ -10,16 +10,6 @@ end
require("lazyvim.config").init() require("lazyvim.config").init()
-- Terminal Mappings
local function term_nav(dir)
---@param self snacks.terminal
return function(self)
return self:is_floating() and "<c-" .. dir .. ">" or vim.schedule(function()
vim.cmd.wincmd(dir)
end)
end
end
return { return {
{ "folke/lazy.nvim", version = "*" }, { "folke/lazy.nvim", version = "*" },
{ "LazyVim/LazyVim", priority = 10000, lazy = false, opts = {}, cond = true, version = "*" }, { "LazyVim/LazyVim", priority = 10000, lazy = false, opts = {}, cond = true, version = "*" },
@ -27,37 +17,7 @@ return {
"folke/snacks.nvim", "folke/snacks.nvim",
priority = 1000, priority = 1000,
lazy = false, lazy = false,
opts = function() opts = {},
---@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 = { "<C-h>", term_nav("h"), desc = "Go to Left Window", expr = true, mode = "t" },
nav_j = { "<C-j>", term_nav("j"), desc = "Go to Lower Window", expr = true, mode = "t" },
nav_k = { "<C-k>", term_nav("k"), desc = "Go to Upper Window", expr = true, mode = "t" },
nav_l = { "<C-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 = {
{ "<leader>.", function() Snacks.scratch() end, desc = "Toggle Scratch Buffer" },
{ "<leader>S", function() Snacks.scratch.select() end, desc = "Select Scratch Buffer" },
{ "<leader>n", function() Snacks.notifier.show_history() end, desc = "Notification History" },
{ "<leader>un", function() Snacks.notifier.hide() end, desc = "Dismiss All Notifications" },
},
config = function(_, opts) config = function(_, opts)
local notify = vim.notify local notify = vim.notify
require("snacks").setup(opts) require("snacks").setup(opts)

View file

@ -265,7 +265,27 @@ return {
{ "MunifTanjim/nui.nvim", lazy = true }, { "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 = {
{ "<leader>.", function() Snacks.scratch() end, desc = "Toggle Scratch Buffer" },
{ "<leader>S", function() Snacks.scratch.select() end, desc = "Select Scratch Buffer" },
{ "<leader>n", function() Snacks.notifier.show_history() end, desc = "Notification History" },
{ "<leader>un", function() Snacks.notifier.hide() end, desc = "Dismiss All Notifications" },
},
},
{
"snacks.nvim",
opts = { opts = {
dashboard = { dashboard = {
preset = { preset = {

View file

@ -1,5 +1,34 @@
-- Terminal Mappings
local function term_nav(dir)
---@param self snacks.terminal
return function(self)
return self:is_floating() and "<c-" .. dir .. ">" or vim.schedule(function()
vim.cmd.wincmd(dir)
end)
end
end
return { return {
-- Snacks utils
{
"snacks.nvim",
opts = {
bigfile = { enabled = true },
quickfile = { enabled = true },
terminal = {
win = {
keys = {
nav_h = { "<C-h>", term_nav("h"), desc = "Go to Left Window", expr = true, mode = "t" },
nav_j = { "<C-j>", term_nav("j"), desc = "Go to Lower Window", expr = true, mode = "t" },
nav_k = { "<C-k>", term_nav("k"), desc = "Go to Upper Window", expr = true, mode = "t" },
nav_l = { "<C-l>", term_nav("l"), desc = "Go to Right Window", expr = true, mode = "t" },
},
},
},
},
},
-- Session management. This saves your session in the background, -- Session management. This saves your session in the background,
-- keeping track of open buffers, window arrangement, and more. -- keeping track of open buffers, window arrangement, and more.
-- You can restore sessions when returning through the dashboard. -- You can restore sessions when returning through the dashboard.