Improve icon fetching by file extension (#423)

This commit is contained in:
Luís Simas
2021-06-01 15:40:00 -03:00
committed by GitHub
parent aa026ab87c
commit be784713d5
2 changed files with 5 additions and 2 deletions

View File

@@ -58,11 +58,14 @@ if icon_state.show_file_icon then
get_file_icon = function(fname, extension, line, depth)
local icon, hl_group = web_devicons.get_icon(fname, extension)
if icon then
if icon and hl_group ~= "DevIconDefault" then
if hl_group then
table.insert(hl, { hl_group, line, depth, depth + #icon + 1 })
end
return icon.." "
elseif string.match(extension, "%.(.*)") then
-- If there are more extensions to the file, try to grab the icon for them recursively
return get_file_icon(fname, string.match(extension, "%.(.*)"), line, depth)
else
return #icon_state.icons.default > 0 and icon_state.icons.default.." " or ""
end