famiu/feline.nvim

[Bug] Feline `file` provider not resolving the correct icon color

mehalter opened this issue · 5 comments

Neovim version

NVIM v0.7.0                                                                                                                    Build type: Release                                                                                                            LuaJIT 2.1.0-beta3                                                                                                             Compiled by builduser 

Feline version
master branch

Describe the bug
Feline file provider colored icon not respecting custom nvim-web-devicons highlight groups

To Reproduce
Steps to reproduce the behavior:

  1. Set up custom highlight for nvim-web-devicons
  2. Add file provider with colored icon
  3. Check color

Expected behavior
I would expect the colors to match what I have set in the nvim-web-devicons. I am making sure that we are loading and setting up nvim-web-devicons before feline as well. Also I checked the code for bufferline (which works correctly) and they seem to be using the same get_icon function as well so I'm not sure what's causing the issue (https://github.com/akinsho/bufferline.nvim/blob/2d5266d14b7b5dbc54923469b4599f0349f7cedc/lua/bufferline/utils.lua#L262)

Note: It does seem to correctly resolve icons that I have added in my nvim-web-devicon setup correctly like if I add an icon for .deb or .zip that don't come out of the box but they show up not colored at all because it's not getting the correct color.

Here is a screenshot showing the resolved file type icon color in both bufferline (above and correct) and feline (below and incorrectly showing the default color)

2022-05-08_15:12:06_screenshot

  1. Set up custom highlight for nvim-web-devicons

Are you using require("nvim-web-devicons").set_icon() to do it?
Cannot reproduce

I am relying on just setting the correct highlight groups so that it supports any colorscheme's specific icon colors. The nvim-web-devicons setup function checks these highlight groups when it sets up each icon automatically if they exist and refreshes them on ColorScheme event with an autocommand @xeluxee

Ah I think this is because feline is getting the color from the nvim-web-devicon instead of the highlight group. If you do local icon_str, hlgroup_str = require("nvim-web-devicons").get_icon(filename, nil, { default = true }) it will return the highlight group name instead of the "color" set by nvim-web-devicon. The setup function sets up the highlight groups when the setup is called so all of the other plugins rely on that instead of getting the color so that it's more extensible. Maybe Feline should move to this method instead of the actual color.

I will make a PR to propose a fix for this!

This has been resolved upstream in nvim-web-devicons