From 60bfbe05da1a0adb0b3ed28ac055cd23528b764e Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 23 Feb 2026 15:16:25 -0500 Subject: [PATCH] fix: preserve devicons highlight groups in nonicons icon provider Problem: when the nonicons direct API was detected, all icons were returned with the generic 'OilFileIcon' highlight group, losing per-filetype colors from nvim-web-devicons. Solution: resolve highlight groups from devicons when available so nonicons glyphs retain their per-filetype colors. --- lua/oil/util.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lua/oil/util.lua b/lua/oil/util.lua index 1ba9872..8e739a8 100644 --- a/lua/oil/util.lua +++ b/lua/oil/util.lua @@ -947,23 +947,26 @@ M.get_icon_provider = function() local has_nonicons, nonicons = pcall(require, 'nonicons') if has_nonicons and nonicons.get_icon then + local _, devicons = pcall(require, 'nvim-web-devicons') 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 + local hl = devicons and select(2, devicons.get_icon(name)) or 'OilFileIcon' if ft then local ft_icon = nonicons.get_icon_by_filetype(ft) if ft_icon then - return ft_icon, 'OilFileIcon' + local ft_hl = devicons and select(2, devicons.get_icon_by_filetype(ft)) + return ft_icon, ft_hl or hl end end local icon = nonicons.get_icon(name) if icon then - return icon, 'OilFileIcon' + return icon, hl end local fallback = nonicons.get('file') - return fallback or (conf and conf.default_file or ''), 'OilFileIcon' + return fallback or (conf and conf.default_file or ''), hl end end