Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#498): set_icons failed when called before setup #499

Merged
merged 2 commits into from
Sep 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading