Skip to content

Commit

Permalink
fix(#261 #287): persist icon overrides when changing &background (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
ribru17 authored Jan 6, 2024
1 parent 3e24abe commit db0c864
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions lua/nvim-web-devicons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ function M.get_icons()
return icons
end

local global_opts = {
override = {},
strict = false,
default = false,
color_icons = true,
}

-- Set the current icons tables, depending on the 'background' option.
local function refresh_icons()
local theme
Expand All @@ -20,6 +27,7 @@ local function refresh_icons()
icons_by_file_extension = theme.icons_by_file_extension
icons_by_operating_system = theme.icons_by_operating_system
icons = vim.tbl_extend("keep", {}, icons_by_filename, icons_by_file_extension, icons_by_operating_system)
icons = vim.tbl_extend("force", icons, global_opts.override)
end

-- Map of filetypes -> icon names
Expand Down Expand Up @@ -229,13 +237,6 @@ local default_icon = {
name = "Default",
}

local global_opts = {
override = {},
strict = false,
default = false,
color_icons = true,
}

local function get_highlight_name(data)
if not global_opts.color_icons then
data = default_icon
Expand Down Expand Up @@ -336,6 +337,13 @@ function M.setup(opts)

icons =
vim.tbl_extend("force", icons, user_icons.override or {}, user_filename_icons or {}, user_file_ext_icons or {})
global_opts.override = vim.tbl_extend(
"force",
global_opts.override,
user_icons.override or {},
user_filename_icons or {},
user_file_ext_icons or {}
)

if user_filename_icons then
icons_by_filename = vim.tbl_extend("force", icons_by_filename, user_filename_icons)
Expand Down

0 comments on commit db0c864

Please sign in to comment.