Skip to content

Commit

Permalink
fix(icons): check for get_icons returning nil (#483)
Browse files Browse the repository at this point in the history
It is possible to define new icons with `nvim-web-devicons`, and _not_
define a color for them.
  • Loading branch information
Iron-E authored May 8, 2023
1 parent db6fcc1 commit 31b4f70
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lua/barbar/icons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ icons.get_icon = ok and
function(bufnr, buffer_activity)
local basename, extension = '', ''
local filetype = buf_get_option(bufnr, 'filetype')
local icon_char, icon_hl = '', ''
local icon_char, icon_hl = '', 'Buffer'

-- nvim-web-devicon only handles filetype icons, not other types (eg directory)
-- thus we need to do some work here
Expand All @@ -61,7 +61,10 @@ icons.get_icon = ok and
extension = fnamemodify(basename, ':e')
end

icon_char, icon_hl = web.get_icon(basename, extension, { default = true })
local char, group = web.get_icon(basename, extension, { default = true })

if char ~= nil then icon_char = char end
if group ~= nil then icon_hl = group end
end

if icon_hl and hlexists(icon_hl .. buffer_activity) < 1 then
Expand Down

0 comments on commit 31b4f70

Please sign in to comment.