Skip to content

Commit

Permalink
fix(sources-path): file icons not selected using filetype as fallback
Browse files Browse the repository at this point in the history
Bug:	When fail to find an icon using the filename, the path source
	does not try to find an icon using the filetype as fallback.
Fix:	This is because `default` is set when calling `get_icon()` with
	the filename, we should explicitly set `default` to `false`
	so that the icon returned is `nil` instead of the default icon
	when no matching icon is found for the filepath and we can
	try to find an icon using the filetype afterwards.
  • Loading branch information
bekaboo committed Sep 25, 2024
1 parent ede945e commit 01ed539
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lua/dropbar/sources/path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ local function get_icon_and_hl(path)
if icon_kind_opts.use_devicons then
local devicons_ok, devicons = pcall(require, 'nvim-web-devicons')
if devicons_ok and stat and stat.type ~= 'directory' then
-- Try to find icon using the filename, explicitly disable the
-- default icon so that we can try to find the icon using the
-- filetype if the filename does not have a corresponding icon
local devicon, devicon_hl = devicons.get_icon(
vim.fs.basename(path),
vim.fn.fnamemodify(path, ':e'),
{ default = true }
{ default = false }
)
-- No corresponding devicon found using the filename, try finding icon
-- with filetype if the file is loaded as a buf in nvim
Expand Down

0 comments on commit 01ed539

Please sign in to comment.