Skip to content

Commit b8221e4

Browse files
asirykalex-courtis
andauthored
feat: add global blend option (#609)
* feat: add blend option for hl groups to global_opts * chore: fix formatting --------- Co-authored-by: Alexander Courtis <alex@courtis.org>
1 parent 19ce5da commit b8221e4

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ require'nvim-web-devicons'.setup {
119119
-- set the light or dark variant manually, instead of relying on `background`
120120
-- (default to nil)
121121
variant = "light|dark";
122+
-- override blend value for all highlight groups :h highlight-blend.
123+
-- setting this value to `0` will make all icons opaque. in practice this means
124+
-- that icons width will not be affected by pumblend option (see issue #608)
125+
-- (default to nil)
126+
blend = 0;
122127
-- same as `override` but specifically for overrides by filename
123128
-- takes effect when `strict` is true
124129
override_by_filename = {

lua/nvim-web-devicons.lua

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ local global_opts = {
5353
default = false,
5454
color_icons = true,
5555
variant = nil,
56+
blend = nil,
5657
}
5758

5859
---Change all keys in a table to lowercase
@@ -129,10 +130,16 @@ local function set_up_highlight(icon_data)
129130

130131
local hl_group = get_highlight_name(icon_data)
131132
if hl_group and (icon_data.color or icon_data.cterm_color) then
132-
nvim_set_hl(0, get_highlight_name(icon_data), {
133+
local hl_def = {
133134
fg = icon_data.color,
134135
ctermfg = tonumber(icon_data.cterm_color),
135-
})
136+
}
137+
138+
if global_opts.blend then
139+
hl_def.blend = global_opts.blend
140+
end
141+
142+
nvim_set_hl(0, get_highlight_name(icon_data), hl_def)
136143
end
137144
end
138145

@@ -292,6 +299,10 @@ function M.setup(opts)
292299
refresh_icons()
293300
end
294301

302+
if type(user_icons.blend) == "number" then
303+
global_opts.blend = user_icons.blend
304+
end
305+
295306
apply_user_icons()
296307

297308
M.set_up_highlights()

0 commit comments

Comments
 (0)