nvim-tree/nvim-web-devicons

Custom icons not working on latest nvim nightly

rodhash opened this issue · 7 comments

Just updated to the latest neovim nightly due to some recent bugs fixes and noticed that icons from this plugin weren't working anymore.

When I run my previous Nvim version NVIM v0.10.0-dev-a84b454 this plugin still works but when I run NVIM v0.10.0-dev-3020+g435dee74b the customized icons no longer show up.

I'm currently on latest commit:

nvim-web-devicons: 27eac98

image

Attempted replication with freshly built master neovim 05be00a2d however it looks to be working:

20240429_101834

What do you see? Above uses the nvim-tree minimal configuration bug report template - it would be great if you tried that.

Sorry I did not see the bug report template, it seems this option was not there when I created the issue .. but here it is a minimal version I'm testing right now:

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/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", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "nvim-lua/plenary.nvim",
  "MunifTanjim/nui.nvim",
  "rcarriga/nvim-notify",

  -- ft
  "nathom/filetype.nvim",

  -- icons
  "nvim-tree/nvim-web-devicons",
  "nvim-tree/nvim-tree.lua"
}


require("lazy").setup(plugins, {
  root = root .. "/plugins",
})


-- add anything else here
require("nvim-tree").setup()

require'nvim-web-devicons'.setup {
 override = {
  zsh = {
    icon = "",
    color = "#428850",
    cterm_color = "65",
    name = "Zsh"
  }
 };
 color_icons = true;
 default = true;
 strict = true;
 override_by_filename = {
  [".gitignore"] = {
    icon = "x",
    color = "#f1502f",
    name = "Gitignore"
  },
 };
 -- same as `override` but specifically for overrides by extension
 -- takes effect when `strict` is true
 override_by_extension = {
  ["log"] = {
    icon = "",
    color = "#81e043",
    name = "Log"
  },
  ["py"] = {
    icon = "x",
    color = "#f1502f",
    name = "Python"
  }
 };
 -- same as `override` but specifically for operating system
 -- takes effect when `strict` is true
 override_by_operating_system = {
  ["apple"] = {
    icon = "",
    color = "#A2AAAD",
    cterm_color = "248",
    name = "Apple",
  },
 };
}

I mean, the plugin works but it shows only the default icons, it's not showing up customized icons such as the Python I've included in the template above or the .gitignore.

For me it uses the normal icons not the "x".

Replace the ; with , in the table you pass to setup, remove strict and it should work for you.

Hmm not sure where those ; came from .. in my main config I don't have any, for some reason I added those ; while building this minimal config.

Am I missing something else? Because with this minimal config I still don't see customized icons for python / .gitignore.

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/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", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "nvim-lua/plenary.nvim",
  "MunifTanjim/nui.nvim",
  "rcarriga/nvim-notify",

  -- ft
  "nathom/filetype.nvim",

  -- icons
  "nvim-tree/nvim-web-devicons",
  "nvim-tree/nvim-tree.lua"
}


require("lazy").setup(plugins, {
  root = root .. "/plugins",
})


-- add anything else here
require("nvim-tree").setup()

require'nvim-web-devicons'.setup {
 override = {
  zsh = {
    icon = "",
    color = "#428850",
    cterm_color = "65",
    name = "Zsh"
  }
 },
 color_icons = true,
 default = true,
 strict = false,
 override_by_filename = {
  [".gitignore"] = {
    icon = "x",
    color = "#f1502f",
    name = "Gitignore"
  },
 },
 -- same as `override` but specifically for overrides by extension
 -- takes effect when `strict` is true
 override_by_extension = {
  ["log"] = {
    icon = "",
    color = "#81e043",
    name = "Log"
  },
  ["py"] = {
    icon = "x",
    color = "#f1502f",
    name = "Python"
  }
 },
 -- same as `override` but specifically for operating system
 -- takes effect when `strict` is true
 override_by_operating_system = {
  ["apple"] = {
    icon = "",
    color = "#A2AAAD",
    cterm_color = "248",
    name = "Apple",
  },
 },
}

Thanks

It looks like a lazy plugin loading issue. I do NOT recommend using lazy loading.

Move nvim-tree setup to the end and see how you go.

Hmmm that's a good point

Added this to the minimal config in order to force the plugin to not lazy load:

  -- icons
  {"nvim-tree/nvim-web-devicons", lazy = false},
  {"nvim-tree/nvim-tree.lua", lazy = false}

Yet it keeps using only the default icons. Then after moving Nvim-Tree to the end, it worked

It's weird that setting lazy to false didn't do the trick .. but at least we know it's working fine now

This issue happened only after updating to the latest Nvim btw .. if I use the previous one this issue doesn't happen, not really sure what happened here but it's working fine after moving to the bottom

Thank you!