@@ -38,13 +38,22 @@ function M.mode_bg() return config.modes[vim.fn.mode()][2] end
3838--- @return table # the highlight group for the current filetype foreground
3939-- @usage local heirline_component = { provider = require("astroui.status").provider.fileicon(), hl = require("astroui.status").hl.filetype_color },
4040function M .filetype_color (self )
41- local devicons_avail , devicons = pcall (require , " nvim-web-devicons" )
42- if not devicons_avail then return {} end
43- local _ , color = devicons .get_icon_color (
44- vim .fn .fnamemodify (vim .api .nvim_buf_get_name (self and self .bufnr or 0 ), " :t" ),
45- nil ,
46- { default = true }
47- )
41+ local color
42+ local bufnr = self and self .bufnr or 0
43+ local bufname = vim .fn .fnamemodify (vim .api .nvim_buf_get_name (bufnr ), " :t" )
44+
45+ local mini_icons_avail , mini_icons = pcall (require , " mini.icons" )
46+ if mini_icons_avail then -- mini.icons
47+ local _ , hl = mini_icons .get (" file" , bufname )
48+ color = require (" astroui" ).get_hlgroup (hl ).fg
49+ if type (color ) == " number" then color = string.format (" #%06x" , color ) end
50+ else -- nvim-web-devicons
51+ local devicons_avail , devicons = pcall (require , " nvim-web-devicons" )
52+ if devicons_avail then
53+ _ , color = devicons .get_icon_color (bufname , nil , { default = true })
54+ end
55+ end
56+
4857 return { fg = color }
4958end
5059
0 commit comments