feat(icons): add nonicons.nvim icon provider support
Problem: oil.nvim only recognizes mini.icons and nvim-web-devicons as
icon providers. nonicons.nvim works when paired with devicons (via its
apply() monkey-patch), but has no standalone support.
Solution: add a nonicons.nvim fallback in get_icon_provider(), placed
after devicons so the patched devicons path is preferred when both are
installed. The standalone path handles directories via
nonicons.get('file-directory'), files via filetype/extension lookup with
a generic file icon fallback.
This commit is contained in:
parent
b6aaeaf542
commit
6859272535
2 changed files with 29 additions and 3 deletions
|
|
@ -22,9 +22,9 @@ https://user-images.githubusercontent.com/506791/209727111-6b4a11f4-634a-4efa-94
|
|||
|
||||
- Neovim 0.10+
|
||||
- Optional:
|
||||
[mini.icons](https://github.com/nvim-mini/mini.nvim/blob/main/readmes/mini-icons.md)
|
||||
or [nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons) for
|
||||
file icons
|
||||
[mini.icons](https://github.com/nvim-mini/mini.nvim/blob/main/readmes/mini-icons.md),
|
||||
[nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons), or
|
||||
[nonicons.nvim](https://github.com/barrettruth/nonicons.nvim) for file icons
|
||||
|
||||
## Installation
|
||||
|
||||
|
|
|
|||
|
|
@ -965,6 +965,32 @@ M.get_icon_provider = function()
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
local has_nonicons, nonicons = pcall(require, 'nonicons')
|
||||
if has_nonicons and type(nonicons.get) == 'function' 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'
|
||||
else
|
||||
if ft then
|
||||
local ft_icon = nonicons.get(ft)
|
||||
if ft_icon then
|
||||
return ft_icon, 'OilFileIcon'
|
||||
end
|
||||
end
|
||||
local ext = name:match('%.([^%.]+)$')
|
||||
if ext then
|
||||
local ext_icon = nonicons.get(ext)
|
||||
if ext_icon then
|
||||
return ext_icon, 'OilFileIcon'
|
||||
end
|
||||
end
|
||||
local icon = nonicons.get('file')
|
||||
return icon or (conf and conf.default_file or ''), 'OilFileIcon'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---Read a buffer into a scratch buffer and apply syntactic highlighting when possible
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue