diff --git a/README.md b/README.md index 0dffd17d8..fd05bc982 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,11 @@ use 'nvim-tree/nvim-web-devicons' Light or dark color variants of the icons depend on `&background`. -These will be updated following `OptionSet` `background` however be advised that the plugin using nvim-web-devicons may have cached the icons. +The variant is updated: +- on `OptionSet` event for `background`, or +- after explicitly calling `require("nvim-web-devicons").refresh()`. + +However, be advised that the plugin using nvim-web-devicons may have cached the icons. ### Setup diff --git a/lua/nvim-web-devicons.lua b/lua/nvim-web-devicons.lua index 7af607461..9b70b1362 100644 --- a/lua/nvim-web-devicons.lua +++ b/lua/nvim-web-devicons.lua @@ -2091,13 +2091,15 @@ end -- Load the icons already, the loaded tables depend on the 'background' setting. refresh_icons() +local function refresh() + refresh_icons() + set_up_highlights(true) +end + -- Change icon set on background change vim.api.nvim_create_autocmd("OptionSet", { pattern = "background", - callback = function() - refresh_icons() - set_up_highlights(true) -- Force update highlights - end, + callback = refresh, }) return { @@ -2121,4 +2123,5 @@ return { return icons end, set_up_highlights = set_up_highlights, + refresh = refresh, }