mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-28 06:34:42 +02:00
refactor(icons): move devicons stuff to util.mini
This commit is contained in:
parent
208cf5f125
commit
8e92c868ff
2 changed files with 32 additions and 35 deletions
|
@ -303,41 +303,7 @@ return {
|
||||||
},
|
},
|
||||||
|
|
||||||
-- icons
|
-- icons
|
||||||
{
|
{ "echasnovski/mini.icons", lazy = true, opts = {}, init = LazyVim.mini.devicons },
|
||||||
"echasnovski/mini.icons",
|
|
||||||
lazy = true,
|
|
||||||
opts = {},
|
|
||||||
init = function()
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
|
|
||||||
-- ui components
|
-- ui components
|
||||||
{ "MunifTanjim/nui.nvim", lazy = true },
|
{ "MunifTanjim/nui.nvim", lazy = true },
|
||||||
|
|
|
@ -148,4 +148,35 @@ function M.pairs(opts)
|
||||||
end
|
end
|
||||||
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
|
return M
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue