Open eemed opened 4 years ago
This is is because most themes include a hi clear
, which cleans any colourizer_mb_..
highlights and colorizer wont re-do work it's already done.
Workaround
Remove colorizer from memory and recall setup
after reloading your theme to enforce it into recreating those highlight groups.
:lua package.loaded['colorizer'] = nil; require('colorizer').setup(...); require('colorizer').attach_to_buffer(0)
(Technically this doesn't remove the two sub packages (colorizer.nvim and colorizer.trie), but those just contain helper functions, no in-memory state.)
Cause (?)
I haven't looked too hard at the code, but I believe because rehighlight_buffer
calls to initialize_trie
, which checks if the trie's already in memory and won't recreate it if so,
This means when colorizer
is re-attached to any buffers, the trie basically says we've already made a group for these colours, so don't bother, just use the existing highlight, when infact those groups are now cleared of any styling.
Removing the groups manually (hi colorizier_mb_... NONE
) doesn't solve the issue, so I don't believe there's any group look-up occurring, at least not directly. Somewhere in colorizer it's getting cached though (be that in the trie or elsewhere).
A "simple™" fix might be:
nuke_trie()
function that users can call if they know they want to restart everything, or@rktjmp That works really well!
:lua package.loaded['colorizer'] = nil; require('colorizer').setup(...); require('colorizer').attach_to_buffer(0)
So I tried to change require('colorizer').attach_to_buffer(0)
to require('colorizer').reload_all_buffers()
, as it is Shortcut for ColorizerAttachToBuffer on every buffer. But it doesn't work. So I'll use your solution for now.
Describe the bug Edit a vim colorscheme file with some hex color codes and use colorizer. Source the file with
:so%
. Colorization disappears and it cannot be re-enabled in anyway.To Reproduce
:ColorizerAttachToBuffer
:so%
Expected behavior Colors don't disappear. Or atleast should be able to use
:ColorizerReloadAllBuffers
to fix it.Operating System: Debian 10
Neovim Version: 0.4.2
Colorizer Version: Paste the output of 35f1aad99c4d03217bcc80a2e16efe3ba74379a4