mirror of
https://github.com/folke/snacks.nvim
synced 2025-07-07 21:25:11 +00:00
209 lines
5.9 KiB
Lua
209 lines
5.9 KiB
Lua
local M = {}
|
|
|
|
---@type table<string, snacks.dashboard.Section>
|
|
M.examples = {}
|
|
|
|
-- Similar to the Emacs Doom dashboard
|
|
-- 
|
|
M.examples.doom = {
|
|
sections = {
|
|
{ section = "header" },
|
|
{ section = "keys", gap = 1, padding = 1 },
|
|
{ section = "startup" },
|
|
},
|
|
}
|
|
|
|
-- Similar to the Vim Startify dashboard
|
|
-- 
|
|
M.examples.startify = {
|
|
formats = {
|
|
key = function(item)
|
|
return { { "[", hl = "special" }, { item.key, hl = "key" }, { "]", hl = "special" } }
|
|
end,
|
|
},
|
|
sections = {
|
|
{ section = "terminal", cmd = "fortune -s | cowsay", hl = "header", padding = 1, indent = 8 },
|
|
{ title = "MRU", padding = 1 },
|
|
{ section = "recent_files", limit = 8, padding = 1 },
|
|
{ title = "MRU ", file = vim.fn.fnamemodify(".", ":~"), padding = 1 },
|
|
{ section = "recent_files", cwd = true, limit = 8, padding = 1 },
|
|
{ title = "Sessions", padding = 1 },
|
|
{ section = "projects", padding = 1 },
|
|
{ title = "Bookmarks", padding = 1 },
|
|
{ section = "keys" },
|
|
},
|
|
}
|
|
|
|
-- A more advanced example using multiple panes
|
|
-- 
|
|
M.examples.advanced = {
|
|
sections = {
|
|
{ section = "header" },
|
|
{
|
|
pane = 2,
|
|
section = "terminal",
|
|
cmd = "colorscript -e square",
|
|
height = 5,
|
|
padding = 1,
|
|
},
|
|
{ section = "keys", gap = 1, padding = 1 },
|
|
{ pane = 2, icon = " ", title = "Recent Files", section = "recent_files", indent = 2, padding = 1 },
|
|
{ pane = 2, icon = " ", title = "Projects", section = "projects", indent = 2, padding = 1 },
|
|
{
|
|
pane = 2,
|
|
icon = " ",
|
|
title = "Git Status",
|
|
section = "terminal",
|
|
enabled = function()
|
|
return Snacks.git.get_root() ~= nil
|
|
end,
|
|
cmd = "git status --short --branch --renames",
|
|
height = 5,
|
|
padding = 1,
|
|
ttl = 5 * 60,
|
|
indent = 3,
|
|
},
|
|
{ section = "startup" },
|
|
},
|
|
}
|
|
|
|
-- Advanced example using the GitHub CLI.
|
|
-- 
|
|
M.examples.github = {
|
|
sections = {
|
|
{ section = "header" },
|
|
{
|
|
pane = 2,
|
|
section = "terminal",
|
|
cmd = "colorscript -e square",
|
|
height = 5,
|
|
padding = 1,
|
|
},
|
|
{ section = "keys", gap = 1, padding = 1 },
|
|
{
|
|
pane = 2,
|
|
icon = " ",
|
|
desc = "Browse Repo",
|
|
padding = 1,
|
|
key = "b",
|
|
action = function()
|
|
Snacks.gitbrowse()
|
|
end,
|
|
},
|
|
function()
|
|
local in_git = Snacks.git.get_root() ~= nil
|
|
local cmds = {
|
|
{
|
|
title = "Notifications",
|
|
cmd = "gh notify -s -a -n5",
|
|
action = function()
|
|
vim.ui.open("https://github.com/notifications")
|
|
end,
|
|
key = "n",
|
|
icon = " ",
|
|
height = 5,
|
|
enabled = true,
|
|
},
|
|
{
|
|
title = "Open Issues",
|
|
cmd = "gh issue list -L 3",
|
|
key = "i",
|
|
action = function()
|
|
vim.fn.jobstart("gh issue list --web", { detach = true })
|
|
end,
|
|
icon = " ",
|
|
height = 7,
|
|
},
|
|
{
|
|
icon = " ",
|
|
title = "Open PRs",
|
|
cmd = "gh pr list -L 3",
|
|
key = "P",
|
|
action = function()
|
|
vim.fn.jobstart("gh pr list --web", { detach = true })
|
|
end,
|
|
height = 7,
|
|
},
|
|
{
|
|
icon = " ",
|
|
title = "Git Status",
|
|
cmd = "git --no-pager diff --stat -B -M -C",
|
|
height = 10,
|
|
},
|
|
}
|
|
return vim.tbl_map(function(cmd)
|
|
return vim.tbl_extend("force", {
|
|
pane = 2,
|
|
section = "terminal",
|
|
enabled = in_git,
|
|
padding = 1,
|
|
ttl = 5 * 60,
|
|
indent = 3,
|
|
}, cmd)
|
|
end, cmds)
|
|
end,
|
|
{ section = "startup" },
|
|
},
|
|
}
|
|
|
|
-- A simple example with a header, keys, recent files, and projects
|
|
-- 
|
|
M.examples.files = {
|
|
sections = {
|
|
{ section = "header" },
|
|
{ section = "keys", gap = 1 },
|
|
{ icon = " ", title = "Recent Files", section = "recent_files", indent = 2, padding = { 2, 2 } },
|
|
{ icon = " ", title = "Projects", section = "projects", indent = 2, padding = 2 },
|
|
{ section = "startup" },
|
|
},
|
|
}
|
|
|
|
-- A more compact version of the `files` example
|
|
-- 
|
|
M.examples.compact_files = {
|
|
sections = {
|
|
{ section = "header" },
|
|
{ icon = " ", title = "Keymaps", section = "keys", indent = 2, padding = 1 },
|
|
{ icon = " ", title = "Recent Files", section = "recent_files", indent = 2, padding = 1 },
|
|
{ icon = " ", title = "Projects", section = "projects", indent = 2, padding = 1 },
|
|
{ section = "startup" },
|
|
},
|
|
}
|
|
|
|
-- An example using the `chafa` command to display an image
|
|
-- 
|
|
M.examples.chafa = {
|
|
sections = {
|
|
{
|
|
section = "terminal",
|
|
cmd = "chafa ~/.config/wall.png --format symbols --symbols vhalf --size 60x17 --stretch; sleep .1",
|
|
height = 17,
|
|
padding = 1,
|
|
},
|
|
{
|
|
pane = 2,
|
|
{ section = "keys", gap = 1, padding = 1 },
|
|
{ section = "startup" },
|
|
},
|
|
},
|
|
}
|
|
|
|
-- Pokemons, because why not?
|
|
-- 
|
|
M.examples.pokemon = {
|
|
sections = {
|
|
{ section = "header" },
|
|
{ section = "keys", gap = 1, padding = 1 },
|
|
{ section = "startup" },
|
|
{
|
|
section = "terminal",
|
|
cmd = "pokemon-colorscripts -r --no-title; sleep .1",
|
|
random = 10,
|
|
pane = 2,
|
|
indent = 4,
|
|
height = 30,
|
|
},
|
|
},
|
|
}
|
|
|
|
return M
|