feat: add get_icon and get_icon_by_filetype API
Some checks are pending
luarocks / quality (push) Waiting to run
luarocks / publish (push) Blocked by required conditions

Problem: plugins that don't use devicons have no way to get nonicons
glyphs for files. The only integration path is the devicons
monkey-patch via apply().

Solution: add get_icon(name, ext) and get_icon_by_filetype(ft) to
the public API in init.lua. Both use lazy require of the resolve
module and return nil on miss so callers decide fallback. Document
both functions in vimdoc and update the oil.nvim recipe.
This commit is contained in:
Barrett Ruth 2026-02-22 21:31:35 -05:00
parent b9a310dc37
commit 6c3e72cf33
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
2 changed files with 44 additions and 2 deletions

View file

@ -40,4 +40,18 @@ function M.apply()
end
end
function M.get_icon(name, ext)
local key = require('nonicons.resolve').resolve_name(name, ext)
if key then
return M.get(key)
end
end
function M.get_icon_by_filetype(ft)
local key = require('nonicons.resolve').resolve_filetype(ft)
if key then
return M.get(key)
end
end
return M