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:
parent
b0f44d3af6
commit
85ec7a407a
1 changed files with 22 additions and 0 deletions
|
|
@ -945,6 +945,28 @@ M.get_icon_provider = function()
|
||||||
end
|
end
|
||||||
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')
|
local has_devicons, devicons = pcall(require, 'nvim-web-devicons')
|
||||||
if has_devicons then
|
if has_devicons then
|
||||||
return function(type, name, conf, ft)
|
return function(type, name, conf, ft)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue