Skip to content

Commit d3c79f1

Browse files
committed
fix(status): correctly display icons for non-file buffers
1 parent 606aaed commit d3c79f1

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lua/astroui/status/component.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ end
3737
-- @usage local heirline_component = require("astroui.status").component.file_info()
3838
function M.file_info(opts)
3939
opts = extend_tbl({
40-
file_icon = { hl = hl.file_icon "statusline", padding = { left = 1, right = 1 }, condition = condition.is_file },
40+
file_icon = { hl = hl.file_icon "statusline", padding = { left = 1, right = 1 } },
4141
filename = false,
4242
filetype = {},
4343
file_modified = { padding = { left = 1 }, condition = condition.is_file },

lua/astroui/status/provider.lua

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,19 +425,20 @@ function M.file_icon(opts)
425425
local ft_icon
426426
local bufnr = self and self.bufnr or 0
427427
local bufname = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufnr), ":t")
428+
local filetype = vim.bo[bufnr].filetype
429+
local is_file = vim.bo[bufnr].buftype == ""
428430

429431
local mini_icons_avail, mini_icons = pcall(require, "mini.icons")
430432
if mini_icons_avail then -- mini.icons
431433
ft_icon, _ = mini_icons.get("file", bufname)
432-
end
433-
434-
if not ft_icon then -- nvim-web-devicons
434+
if ft_icon == mini_icons.get("default", "file") then
435+
ft_icon, _ = mini_icons.get("filetype", filetype)
436+
if ft_icon == mini_icons.get("default", "filetype") and not is_file then ft_icon = nil end
437+
end
438+
else -- nvim-web-devicons
435439
local devicons_avail, devicons = pcall(require, "nvim-web-devicons")
436440
if devicons_avail then
437-
ft_icon, _ = devicons.get_icon(bufname)
438-
if not ft_icon then
439-
ft_icon, _ = devicons.get_icon_by_filetype(vim.bo[bufnr].filetype, { default = true })
440-
end
441+
ft_icon, _ = devicons.get_icon(bufname, filetype, { default = vim.bo[bufnr].buftype == "" })
441442
end
442443
end
443444

0 commit comments

Comments
 (0)