No way to add/override icons for filetypes
classabbyamp opened this issue · 4 comments
the get_icon_*_by_filetype
api relies on the filetypes
local, which cannot be extended or modified externally. this makes it impossible to add an icon for a custom filetype, and because lualine
uses the _by_filetype
api, it cannot use any custom icons.
would it be possible to add a set_icon_by_filetype
or make filetypes
publicly accessible?
this solves my issue
diff --git a/lua/nvim-web-devicons.lua b/lua/nvim-web-devicons.lua
index 4301079..d8b6a73 100644
--- a/lua/nvim-web-devicons.lua
+++ b/lua/nvim-web-devicons.lua
@@ -39,7 +39,7 @@ local function refresh_icons()
end
-- Map of filetypes -> icon names
-local filetypes = {
+M.filetypes = {
["avif"] = "avif",
["bzl"] = "bzl",
["brewfile"] = "brewfile",
@@ -437,7 +437,7 @@ function M.get_icon(name, ext, opts)
end
function M.get_icon_name_by_filetype(ft)
- return filetypes[ft]
+ return M.filetypes[ft]
end
function M.get_icon_by_filetype(ft, opts)
by allowing me to do require("nvim-web-devicons").filetypes["srcpkg"] = "void"
would that be an acceptable change to PR?
That would be great.
Let's use a setter set_icon_by_filetype
please instead of exposing the internals.
Confirmed: no action will be needed in the case of colourscheme change etc.
but inside the setter, that mechanism is the way to go?
but inside the setter, that mechanism is the way to go?
Yes please - completely override or add.