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

feat(#298): add refresh api #301

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you


### Setup

Expand Down
11 changes: 7 additions & 4 deletions lua/nvim-web-devicons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -2121,4 +2123,5 @@ return {
return icons
end,
set_up_highlights = set_up_highlights,
refresh = refresh,
}