mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 19:28:24 +00:00
fix(util): better support for nvim-web-devicons
This commit is contained in:
parent
ca7188c531
commit
ddaa2aaba5
1 changed files with 14 additions and 3 deletions
|
@ -56,10 +56,21 @@ end
|
|||
---@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,
|
||||
function()
|
||||
return require("mini.icons").get(cat or "file", name)
|
||||
end,
|
||||
function()
|
||||
local Icons = require("nvim-web-devicons")
|
||||
if cat == "filetype" then
|
||||
return Icons.get_icon_by_filetype(name, { default = false })
|
||||
elseif cat == "file" then
|
||||
local ext = name:match("%.(%w+)$")
|
||||
return Icons.get_icon(name, ext, { default = false }) --[[@as string, string]]
|
||||
elseif cat == "extension" then
|
||||
return Icons.get_icon(nil, name, { default = false }) --[[@as string, string]]
|
||||
end
|
||||
end,
|
||||
}
|
||||
for _, fn in ipairs(try) do
|
||||
local ret = { pcall(fn) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue