mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
feat(util): simple function to get an icon
This commit is contained in:
parent
d517b11cab
commit
7c29848e89
3 changed files with 35 additions and 12 deletions
15
README.md
15
README.md
|
@ -156,14 +156,17 @@ See the example below for how to configure `snacks.nvim`.
|
|||
}
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>un", function() Snacks.notifier.hide() end, desc = "Dismiss All Notifications" },
|
||||
{ "<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>bd", function() Snacks.bufdelete() end, desc = "Delete Buffer" },
|
||||
{ "<leader>gg", function() Snacks.lazygit() end, desc = "Lazygit" },
|
||||
{ "<leader>gb", function() Snacks.git.blame_line() end, desc = "Git Blame Line" },
|
||||
{ "<leader>gB", function() Snacks.gitbrowse() end, desc = "Git Browse" },
|
||||
{ "<leader>gf", function() Snacks.lazygit.log_file() end, desc = "Lazygit Current File History" },
|
||||
{ "<leader>gl", function() Snacks.lazygit.log() end, desc = "Lazygit Log (cwd)" },
|
||||
{ "<leader>cR", function() Snacks.rename.rename_file() end, desc = "Rename File" },
|
||||
{ "<leader>gB", function() Snacks.gitbrowse() end, desc = "Git Browse" },
|
||||
{ "<leader>gb", function() Snacks.git.blame_line() end, desc = "Git Blame Line" },
|
||||
{ "<leader>gf", function() Snacks.lazygit.log_file() end, desc = "Lazygit Current File History" },
|
||||
{ "<leader>gg", function() Snacks.lazygit() end, desc = "Lazygit" },
|
||||
{ "<leader>gl", function() Snacks.lazygit.log() end, desc = "Lazygit Log (cwd)" },
|
||||
{ "<leader>un", function() Snacks.notifier.hide() end, desc = "Dismiss All Notifications" },
|
||||
{ "<c-/>", function() Snacks.terminal() end, desc = "Toggle Terminal" },
|
||||
{ "<c-_>", function() Snacks.terminal() end, desc = "which_key_ignore" },
|
||||
{ "]]", function() Snacks.words.jump(vim.v.count1) end, desc = "Next Reference", mode = { "n", "t" } },
|
||||
|
|
|
@ -21,14 +21,17 @@ return {
|
|||
}
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>un", function() Snacks.notifier.hide() end, desc = "Dismiss All Notifications" },
|
||||
{ "<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>bd", function() Snacks.bufdelete() end, desc = "Delete Buffer" },
|
||||
{ "<leader>gg", function() Snacks.lazygit() end, desc = "Lazygit" },
|
||||
{ "<leader>gb", function() Snacks.git.blame_line() end, desc = "Git Blame Line" },
|
||||
{ "<leader>gB", function() Snacks.gitbrowse() end, desc = "Git Browse" },
|
||||
{ "<leader>gf", function() Snacks.lazygit.log_file() end, desc = "Lazygit Current File History" },
|
||||
{ "<leader>gl", function() Snacks.lazygit.log() end, desc = "Lazygit Log (cwd)" },
|
||||
{ "<leader>cR", function() Snacks.rename.rename_file() end, desc = "Rename File" },
|
||||
{ "<leader>gB", function() Snacks.gitbrowse() end, desc = "Git Browse" },
|
||||
{ "<leader>gb", function() Snacks.git.blame_line() end, desc = "Git Blame Line" },
|
||||
{ "<leader>gf", function() Snacks.lazygit.log_file() end, desc = "Lazygit Current File History" },
|
||||
{ "<leader>gg", function() Snacks.lazygit() end, desc = "Lazygit" },
|
||||
{ "<leader>gl", function() Snacks.lazygit.log() end, desc = "Lazygit Log (cwd)" },
|
||||
{ "<leader>un", function() Snacks.notifier.hide() end, desc = "Dismiss All Notifications" },
|
||||
{ "<c-/>", function() Snacks.terminal() end, desc = "Toggle Terminal" },
|
||||
{ "<c-_>", function() Snacks.terminal() end, desc = "which_key_ignore" },
|
||||
{ "]]", function() Snacks.words.jump(vim.v.count1) end, desc = "Next Reference", mode = { "n", "t" } },
|
||||
|
|
|
@ -52,4 +52,21 @@ function M.bo(buf, bo)
|
|||
end
|
||||
end
|
||||
|
||||
---@param name string
|
||||
---@param cat? string
|
||||
---@return string, string?
|
||||
function M.icon(name, cat)
|
||||
-- stylua: ignore
|
||||
local try = {
|
||||
function() return require("mini.icons").get(cat or "file", name) end,
|
||||
function() return require("nvim-web-devicons").get_icon(name) end,
|
||||
}
|
||||
for _, fn in ipairs(try) do
|
||||
local ret = { pcall(fn) }
|
||||
if ret[1] then
|
||||
return ret[2], ret[3]
|
||||
end
|
||||
end
|
||||
return " "
|
||||
end
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue