feat: add OilFileIcon highlight group for fallback file icons

Problem: when nvim-web-devicons returns no highlight for an unrecognized
file extension, the icon gets nil for its highlight group. Directories
have OilDirIcon as a targetable fallback, but files have nothing.

Solution: define OilFileIcon (linked to nil, matching OilFile) and use
it as the fallback in the devicons provider when get_icon returns a nil
highlight. The mini.icons provider already returns highlights for all
files so only the devicons path needs this.

Resolves: stevearc/oil.nvim#690
This commit is contained in:
Barrett Ruth 2026-02-20 20:23:56 -05:00
parent 85ed9b8a72
commit ce64ae18de
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
2 changed files with 6 additions and 0 deletions

View file

@ -863,6 +863,11 @@ M._get_highlights = function()
link = "OilDir",
desc = "Icon for directories",
},
{
name = "OilFileIcon",
link = nil,
desc = "Icon for files",
},
{
name = "OilSocket",
link = "Keyword",

View file

@ -956,6 +956,7 @@ M.get_icon_provider = function()
end
end
local icon, hl = devicons.get_icon(name)
hl = hl or "OilFileIcon"
icon = icon or (conf and conf.default_file or "")
return icon, hl
end