From 00a8342bce2c915daa769dc794b5af3e29444b95 Mon Sep 17 00:00:00 2001 From: asiryk Date: Sat, 13 Sep 2025 01:10:45 +0300 Subject: [PATCH 1/2] feat: add blend option for hl groups to global_opts --- README.md | 5 +++++ lua/nvim-web-devicons.lua | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eb961b14..58e043d1 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,11 @@ require'nvim-web-devicons'.setup { -- set the light or dark variant manually, instead of relying on `background` -- (default to nil) variant = "light|dark"; + -- override blend value for all highlight groups :h highlight-blend. + -- setting this value to `0` will make all icons opaque. in practice this means + -- that icons width will not be affected by pumblend option (see issue #608) + -- (default to nil) + blend = 0; -- same as `override` but specifically for overrides by filename -- takes effect when `strict` is true override_by_filename = { diff --git a/lua/nvim-web-devicons.lua b/lua/nvim-web-devicons.lua index 43ef9bc8..cd15412e 100644 --- a/lua/nvim-web-devicons.lua +++ b/lua/nvim-web-devicons.lua @@ -53,6 +53,7 @@ local global_opts = { default = false, color_icons = true, variant = nil, + blend = nil, } ---Change all keys in a table to lowercase @@ -129,10 +130,15 @@ local function set_up_highlight(icon_data) local hl_group = get_highlight_name(icon_data) if hl_group and (icon_data.color or icon_data.cterm_color) then - nvim_set_hl(0, get_highlight_name(icon_data), { + + local hl_def = { fg = icon_data.color, ctermfg = tonumber(icon_data.cterm_color), - }) + } + + if global_opts.blend then hl_def.blend = global_opts.blend end + + nvim_set_hl(0, get_highlight_name(icon_data), hl_def) end end @@ -292,6 +298,10 @@ function M.setup(opts) refresh_icons() end + if type(user_icons.blend) == "number" then + global_opts.blend = user_icons.blend + end + apply_user_icons() M.set_up_highlights() From cd7ac8fcf62d62ee8a5b84ded5dc384c8fc2a50f Mon Sep 17 00:00:00 2001 From: asiryk Date: Sun, 28 Sep 2025 15:49:30 +0300 Subject: [PATCH 2/2] chore: fix formatting --- lua/nvim-web-devicons.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/nvim-web-devicons.lua b/lua/nvim-web-devicons.lua index cd15412e..006cab50 100644 --- a/lua/nvim-web-devicons.lua +++ b/lua/nvim-web-devicons.lua @@ -130,13 +130,14 @@ local function set_up_highlight(icon_data) local hl_group = get_highlight_name(icon_data) if hl_group and (icon_data.color or icon_data.cterm_color) then - local hl_def = { fg = icon_data.color, ctermfg = tonumber(icon_data.cterm_color), } - if global_opts.blend then hl_def.blend = global_opts.blend end + if global_opts.blend then + hl_def.blend = global_opts.blend + end nvim_set_hl(0, get_highlight_name(icon_data), hl_def) end