Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot override Lua icon color #462

Closed
ThaiDuy12345 opened this issue May 13, 2024 · 9 comments
Closed

Cannot override Lua icon color #462

ThaiDuy12345 opened this issue May 13, 2024 · 9 comments

Comments

@ThaiDuy12345
Copy link

My configuration:

devicons.setup({
      -- NOTE: override the icon
      override_by_extension = {
        java = { icon = "", color = "#e46368", name = "Java" },
        [".gitignore"] = { icon = "", color = "#428850", name = "GitIgnore" },
        js = { icon = "", color = "#f7cd6d", name = "JavaScript" },
        json = { icon = "", color = "#f7cd6d", name = "JSON" },
        ts = { icon = "󰛦", color = "#87b2e2", name = "TypeScript" },
        html = { icon = "", color = "#de7558", name = "Html" },
        rb = { icon = "", color = "#ef757c", name = "Rb" },
        rake = { icon = "", color = "#ef757c", name = "Rake" },
        rakefile = { icon = "", color = "#ef757c", name = "RakeFile" },
        jbuilder = { icon = "", color = "#f7cd6d", name = "Jbuilder" },
        lua = { icon = "", color = "#37c88e", name = "Lua" }
      },
      color_icons = true,
      default = false,
      strict = true,
})

image
NvimTree:
image

I expected the DevIconLua should be green as same as the highlight color you guys can see in the photo but it's still have the default color. Other icons seem work fine.

@alex-courtis
Copy link
Member

alex-courtis commented May 13, 2024

Execute nvim-web-devicons setup before you execute nvim-tree setup.

What's that plugin that shows the rgb colours after the #? That looks incredibly useful!

20240514_090008

@alex-courtis
Copy link
Member

Raised #464

Added to readme: https://github.com/nvim-tree/nvim-web-devicons?tab=readme-ov-file#my-setup-overrides-are-not-applied

@ThaiDuy12345
Copy link
Author

Execute nvim-web-devicons setup before you execute nvim-tree setup.

What's that plugin that shows the rgb colours after the #? That looks incredibly useful!

20240514_090008

Thanks for the fast response!! 😊 it's from https://github.com/brenoprata10/nvim-highlight-colors

@ThaiDuy12345
Copy link
Author

ThaiDuy12345 commented May 14, 2024

Execute nvim-web-devicons setup before you execute nvim-tree setup.

What's that plugin that shows the rgb colours after the #? That looks incredibly useful!

20240514_090008

I added these property to the plugin which expected Lazy.nvim will load and setup it first, but still didnt work....Not only my nvim-tree, but also bufferline-nvim or incline-nvim and maybe other plugin did not catch the color

image

Incline-nvim:
image

bufferline:
image

Somehow it only wrong for DevIconLua

@ThaiDuy12345
Copy link
Author

UPDATE:

I have got the DevIconLua to change the color, but I have to do an extra line of code after the setup method:

devicons.set_icon({
     java = { icon = "", color = "#e46368", name = "Java" },
     [".gitignore"] = { icon = "", color = "#428850", name = "GitIgnore" },
     js = { icon = "", color = "#f7cd6d", name = "JavaScript" },
     json = { icon = "", color = "#f7cd6d", name = "JSON" },
     ....
})

Dont really know why but it work for me for now

image

@alex-courtis
Copy link
Member

Great news!

#464 should resolve these sorts of problems.

@ThaiDuy12345
Copy link
Author

Great news!

#464 should resolve these sorts of problems.

Cool, will try this out

@mawkler
Copy link
Contributor

mawkler commented Jun 3, 2024

@alex-courtis

Great news!

#464 should resolve these sorts of problems.

#464 seems to be an issue, not a PR. Is there any PR that solves this that I can try out?


I'm having a similar issue where sometimes the color of the override is set to white, even though I've set some other color.

Here's a minimal config that reproduces the issue:

Click to expand
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
  'git',
  'clone',
  '--filter=blob:none',
  'https://github.com/folke/lazy.nvim.git',
  '--branch=stable', -- latest stable release
  lazypath,
})
end
vim.opt.rtp:prepend(lazypath)

vim.keymap.set('n', '<c-q>', vim.cmd.quit)

require('lazy').setup({
  {
    'romgrk/barbar.nvim',
    dependencies = {
      'nvim-tree/nvim-web-devicons',
      opts = {
        override = {
          md = {
            icon = 'THIS TEXT IS SOMETIMES WHITE',
            color = 'red',
            name = 'Markdown'
          },
        },
      }
    },
    opts = {},
  }
})

To reproduce

  1. Open a markdown file with nvim -u path/to/config/above
  2. The text THIS TEXT IS SOMETIMES WHITE is sometimes white, and sometimes red (which it should be)

The issue seems to occur with about a 50% chance.

@alex-courtis
Copy link
Member

I'm having a similar issue where sometimes the color of the override is set to white, even though I've set some other color.

Sometimes is the key. Lazy's ordering is nondeterministic.

Can you try with another plugin manager or call setup yourself afterwards, in the correct order?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants