refactor(icons): move devicons stuff to util.mini

This commit is contained in:
Folke Lemaitre 2024-07-03 17:57:51 +02:00
parent 208cf5f125
commit 8e92c868ff
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 32 additions and 35 deletions

View file

@ -148,4 +148,35 @@ function M.pairs(opts)
end
end
function M.devicons()
package.preload["nvim-web-devicons"] = function()
local Icons = require("mini.icons")
local ret = {}
package.loaded["nvim-web-devicons"] = ret
Icons.mock_nvim_web_devicons()
local function get(cat)
local all = {}
for _, name in ipairs(Icons.list(cat)) do
local icon, color = ret.get_icon_color(cat == "file" and name, cat == "extension" and name)
all[name] = { icon = icon, color = color }
end
return all
end
ret.get_icons_by_extension = function()
return get("extension")
end
ret.get_icons_by_filename = function()
return get("file")
end
ret.get_icons = function()
return vim.tbl_extend("force", get("file"), get("extension"))
end
return ret
end
end
return M