feat(icons): add direct nonicons.nvim icon provider

Problem: nonicons.nvim exposes a public get_icon/get_icon_by_filetype
API, but oil.nvim can only use nonicons glyphs indirectly through the
devicons monkey-patch. This couples oil to devicons even when nonicons
is available standalone.

Solution: add a nonicons provider in get_icon_provider() between
mini.icons and devicons. Feature-gated on nonicons.get_icon existing
so old nonicons versions fall through to devicons. Uses OilDirIcon
and OilFileIcon highlight groups.
This commit is contained in:
Barrett Ruth 2026-02-22 21:24:53 -05:00
parent b0f44d3af6
commit 85ec7a407a
Signed by: barrett
GPG key ID: A6C96C9349D2FC81

View file

@ -945,6 +945,28 @@ M.get_icon_provider = function()
end
end
local has_nonicons, nonicons = pcall(require, 'nonicons')
if has_nonicons and nonicons.get_icon then
return function(type, name, conf, ft)
if type == 'directory' then
local icon = nonicons.get('file-directory')
return icon or (conf and conf.directory or ''), 'OilDirIcon'
end
if ft then
local ft_icon = nonicons.get_icon_by_filetype(ft)
if ft_icon then
return ft_icon, 'OilFileIcon'
end
end
local icon = nonicons.get_icon(name)
if icon then
return icon, 'OilFileIcon'
end
local fallback = nonicons.get('file')
return fallback or (conf and conf.default_file or ''), 'OilFileIcon'
end
end
local has_devicons, devicons = pcall(require, 'nvim-web-devicons')
if has_devicons then
return function(type, name, conf, ft)