nvim-tree / nvim-web-devicons

lua `fork` of vim-web-devicons for neovim
MIT License
1.98k stars 183 forks source link

Overridden icon gets reset on colorscheme change #261

Closed mawkler closed 7 months ago

mawkler commented 1 year ago

Overridden icons get reset when I change colorscheme.

To reproduce:

Configuration:

Click to expand ```lua local root = vim.fn.fnamemodify(vim.fn.expand('$HOME') .. 'nvim-test-config', ':p') 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 = { { 'romgrk/barbar.nvim', config = true }, { 'kyazdani42/nvim-web-devicons', config = function() require('nvim-web-devicons').setup({ override = { md = { icon = '', color = '#519aba', name = 'Markdown' } } }) end, } } require('lazy').setup(plugins, { root = root .. '/plugins', }) ```
  1. nvim -u ~/nvim-test-config/init.lua testfile.md
  2. Notice the custom markdown icon in the top left
  3. :colorscheme blue
  4. :e
  5. Markdown icon is back to the default
alex-courtis commented 1 year ago

Confirmed with nvim-tree

alex-courtis commented 1 year ago

Same applies to changing background.

It looks like we might not be persisting the user data from setup and set_icon.

I'd be most grateful if you could look at this one @mg979

alex-courtis commented 1 year ago

Also noticed that we are not using the "NvimWebDevicons" au group for the "OptionSet" autocommand.

We should do that, as well as create it during setup.

mg979 commented 1 year ago

I think this should be enough, @mawkler can you confirm?

mawkler commented 1 year ago

@mg979 Seems to be working. Thank you!

mikesmithgh commented 1 year ago

workaround: use override_by_filename and override_by_extension. The overrides are persisted for these options (see https://github.com/nvim-tree/nvim-web-devicons/blob/master/lua/nvim-web-devicons.lua#L1915)