Skip to content

Commit

Permalink
fix(file_info): Don't load devicons if component.icon exists
Browse files Browse the repository at this point in the history
  • Loading branch information
famiu committed Sep 17, 2021
1 parent 7416689 commit e461980
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lua/feline/providers/file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,22 @@ function M.file_info(component, winid)
local extension = fn.fnamemodify(filename, ':e')
local readonly_str, modified_str

local icon_str, icon_hlname = require("nvim-web-devicons").get_icon(
filename, extension, { default = true }
)
local icon

-- Avoid loading nvim-web-devicons if an icon is provided already
if not component.icon then
local icon_str, icon_hlname = require("nvim-web-devicons").get_icon(
filename, extension, { default = true }
)

local icon = { str = icon_str }
icon = { str = icon_str }

if component.colored_icon == nil or component.colored_icon then
local fg = api.nvim_get_hl_by_name(icon_hlname, true).foreground
if component.colored_icon == nil or component.colored_icon then
local fg = api.nvim_get_hl_by_name(icon_hlname, true).foreground

if fg then
icon.hl = { fg = string.format('#%06x', fg) }
if fg then
icon.hl = { fg = string.format('#%06x', fg) }
end
end
end

Expand Down

0 comments on commit e461980

Please sign in to comment.