Bug: breaks when buffer temporary lose "buflisted" option
Describe the bug It breaks when i hide buffer from buffer list. It doesn't restore highlihting even after option restoration.
Works on minimal.lua config from Lazy.
To Reproduce Open file with color highlights and type:
:set nobuflisted | set buflisted
Expected behavior It will highlight (after option restoration at least)
Screenshots
before:

after:

Operating System: Archlinux
Neovim Version: v0.8.3
Colorizer Version: dde3084 [master]
Interesting. I will take a look at this.
It looks like when you do :set nobuflisted | set buflisted it triggers the BufDelete event. I have tried checking if the buffer was actually deleted using nvim_buf_is_valid and nvim_buf_is_loaded, but it doesn't behave quite as I would expect.
I'll loop back around to this and take another look.
Can you try with fix/53-no_detach_when_nobuflisted branch?
Since :set nobuflisted triggers the BufDelete event, I added checks to see if the buffer was valid and loaded. From my little testing, I don't think this affects anything else but please try it out and let me know.