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

Overridden icon gets reset on colorscheme change #261

Closed
mawkler opened this issue Apr 29, 2023 · 6 comments · Fixed by #369
Closed

Overridden icon gets reset on colorscheme change #261

mawkler opened this issue Apr 29, 2023 · 6 comments · Fixed by #369

Comments

@mawkler
Copy link
Contributor

mawkler commented Apr 29, 2023

Overridden icons get reset when I change colorscheme.

To reproduce:

Configuration:

Click to expand
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
Copy link
Member

Confirmed with nvim-tree

@alex-courtis
Copy link
Member

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
Copy link
Member

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
Copy link
Collaborator

mg979 commented May 7, 2023

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

@mawkler
Copy link
Contributor Author

mawkler commented May 8, 2023

@mg979 Seems to be working. Thank you!

@mikesmithgh
Copy link

mikesmithgh commented Jul 21, 2023

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)

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