From 01ed539822237652e94ea076f78a44c50bdd634c Mon Sep 17 00:00:00 2001 From: bekaboo <18127878294@qq.com> Date: Tue, 24 Sep 2024 23:55:11 -0400 Subject: [PATCH] fix(sources-path): file icons not selected using filetype as fallback 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. --- lua/dropbar/sources/path.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/dropbar/sources/path.lua b/lua/dropbar/sources/path.lua index b58ed45b..83c133a8 100644 --- a/lua/dropbar/sources/path.lua +++ b/lua/dropbar/sources/path.lua @@ -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