Skip to content

Commit

Permalink
feat: synchronize file type icons with background
Browse files Browse the repository at this point in the history
  • Loading branch information
ismailshak committed Apr 1, 2024
1 parent d38a2a0 commit 384f65f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions lua/barbecue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function M.setup(cfg)
theme.load()

autocmd.create_colorscheme_synchronizer()
autocmd.create_file_icon_color_synchronizer()
if config.user.attach_navic then autocmd.create_navic_attacher() end
if config.user.create_autocmd then autocmd.create_updater() end

Expand Down
15 changes: 15 additions & 0 deletions lua/barbecue/autocmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local theme = require("barbecue.theme")
local GROUP_NAVIC_ATTACHER = "barbecue.navic_attacher"
local GROUP_UPDATER = "barbecue.updater"
local GROUP_COLORSCHEME_SYNCHRONIZER = "barbecue.colorscheme_synchronizer"
local GROUP_FILE_ICONS_SYNCHRONIZER = "barbecue.file_icons_synchronizer"

local M = {}

Expand Down Expand Up @@ -53,4 +54,18 @@ function M.create_colorscheme_synchronizer()
})
end

---Update file type icon colors on background mode change.
---Will only create autocmd if `nvim-web-devicons` is found.
function M.create_file_icon_color_synchronizer()
local devicons_ok = pcall(require, "nvim-web-devicons")
if not devicons_ok then return nil end

vim.api.nvim_create_autocmd("OptionSet", {
pattern = "background",
desc = "File Icon Color Synchronizer",
group = vim.api.nvim_create_augroup(GROUP_FILE_ICONS_SYNCHRONIZER, {}),
callback = function() ui.update() end,
})
end

return M
2 changes: 2 additions & 0 deletions lua/barbecue/theme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,6 @@ function M.get_file_icon(filename, filetype)
}
end

function M.reset_icon_cache() file_icons = {} end

return M

0 comments on commit 384f65f

Please sign in to comment.