Skip to content

Commit

Permalink
fix(#498): set_icons failed when called before setup (#499)
Browse files Browse the repository at this point in the history
* fix(#498): set_icons failed when called before setup

* fix(#498): set_icons failed when called before setup
  • Loading branch information
alex-courtis committed Sep 21, 2024
1 parent 3b83fdd commit 2622015
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lua/nvim-web-devicons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ local global_opts = {
variant = nil,
}

-- Set the current icons tables, depending on the 'background' option.
-- Set the current icons tables, depending on variant option, then &background
local function refresh_icons()
local theme
if global_opts.variant == "light" then
Expand Down Expand Up @@ -381,10 +381,10 @@ function M.setup(opts)

if user_icons.variant == "light" or user_icons.variant == "dark" then
global_opts.variant = user_icons.variant
end

-- Load the icons after setting variant option
refresh_icons()
-- Reload the icons after setting variant option
refresh_icons()
end

if user_icons.override and user_icons.override.default_icon then
default_icon = user_icons.override.default_icon
Expand Down Expand Up @@ -593,6 +593,9 @@ function M.set_default_icon(icon, color, cterm_color)
set_up_highlight(default_icon)
end

-- Load the icons already, the loaded tables depend on the 'background' setting.
refresh_icons()

function M.refresh()
refresh_icons()
M.set_up_highlights(true)
Expand Down

0 comments on commit 2622015

Please # to comment.