nvim-tree / nvim-web-devicons

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

[Proposal] Set different icon color for dark/light background respectively #193

Closed Bekaboo closed 1 year ago

Bekaboo commented 1 year ago

Is it possible to use a different set of colors for light backgrounds? Currently most icons looks great under dark background but some of them are not displayed clearly under light background due to their color:

image image

alex-courtis commented 1 year ago

Currently there is only one set of colours. These opinionated defaults are based on the "recommended" colours e.g. https://github.com/nvim-tree/nvim-web-devicons/pull/190#issuecomment-1401763583

Yes we could add light / dark however that is a significant piece of work.

Pragmatic solution: set your own colours for problematic icons: https://github.com/nvim-tree/nvim-web-devicons#set-an-icon

mg979 commented 1 year ago

The color could be simply inverted. Rather than filling all the icons with the inverted colors, a function could generate the inverted colors on-demand, and cache them in the icons themselves, so that they're generated only once.

There would be the problem of cterm colors, though, since they can't be done on-demand. Maybe with a cheap function.

alex-courtis commented 1 year ago

The color could be simply inverted. Rather than filling all the icons with the inverted colors, a function could generate the inverted colors on-demand, and cache them in the icons themselves, so that they're generated only once.

Good idea, that would be cheap enough.

Could we do it without lifepillar/vim-colortemplate ?

Alternatively, we could generate them at build time. nvim-tree and several other plugins do that to update help, defaults etc.

mg979 commented 1 year ago

Having them all in the same file would basically double the time needed to source the script. Maybe they can stay in a different file (automatically generated at build time), that is only loaded if a light background is being used. If the background changes, also the icons change, without need to add new keys for the light variants.

alex-courtis commented 1 year ago

Having them all in the same file would basically double the time needed to source the script.

Yes.

Would you be happy to put something together? We can profile...

mg979 commented 1 year ago

Yes but I'll keep them in a different file, an autocommand can switch between the two sets. Double time would be too much, and more icons would increase it even more.

alex-courtis commented 1 year ago

Yes but I'll keep them in a different file, an autocommand can switch between the two sets. Double time would be too much, and more icons would increase it even more.

That would be great! Result: zero impact on current users.

mg979 commented 1 year ago

Ok I did it but I'm not sure it's a 100% improvements, inverted colors look less natural than the original ones. Moreover, I tried it with NvimTree and it seems it caches the colors, because unless I start nvim with a light background, I don't see the changes when I switch to a light colorscheme. Anyway I can make a draft PR and you can see it for yourself.

Or more probably it's stuck with those colors because it's what the module returned when it was loaded. So it would need some changes in the plugins to make this work anyway.

alex-courtis commented 1 year ago

Fantastic! I'll get to that one ~this weekend.

alex-courtis commented 1 year ago

Or more probably it's stuck with those colors because it's what the module returned when it was loaded. So it would need some changes in the plugins to make this work anyway.

That's common. See #210