norcalli/nvim-colorizer.lua

[Bug Report] ColorizerToggle doesn't work after switching colorscheme

laggardkernel opened this issue · 9 comments

Describe the bug
I'm using the vim-one colorscheme. Just found after switching background from light to dark, the color highlight is lost.

Command ColorizerToggle works well before changing the background value, but not after that.

Environments

  • Neovim: 0.4.4
  • nvim-colorizer.lua: 36c610a

I got the same problem. Is anybody here?

See also #91.

This repo seems no longer maintained; use this fork instead: https://github.com/NvChad/nvim-colorizer.lua

@wookayin I would like to know about your choice between that maintained fork and this one I'm using. (I found the latter after my last reply. It currently has some trouble regarding large files)

update: Oh sorry, I must be blind in that it is clearly documented there and I didn't see it.

NvChad's one seems much better and well supported (and more community users). I quickly tried the one you pointed (nvim-highlight-colors) but I find that quite buggy, and I think nvim-colorizer.lua is a superset in terms of features and functionalities.

@wookayin But I just tried the one maintained by NvChad, which unfortunately seems buggy regarding the toggle ColorizerToggle. After toggling it off, it's impossible (at least on my machine) to re-enable it using either ColorizerToggle again or ColorizerAttachToBuffer.

This is the code I'm using for your reference:

  -- use {
  --   'NvChad/nvim-colorizer.lua',
  --   config = function ()
  --     require('colorizer').setup {
  --       user_default_options = {
  --         names = false,
  --         css_fn = true, -- Enable all CSS functions: rgb_fn, hsl_fn
  --       }
  --     }
  --     vim.keymap.set('n', '<Leader>ah', function () vim.cmd('ColorizerToggle') end)
  --     -- vim.api.nvim_create_autocmd({ 'ColorScheme' }, {
  --     --   pattern = '*',
  --     --   callback = function () vim.cmd('HighlightColorsOn') end
  --     -- })
  --   end
  -- }
  use {
    'brenoprata10/nvim-highlight-colors',
    config = function ()
      require('nvim-highlight-colors').setup {
        render = 'background',
        enable_named_colors = true,
        enable_tailwind = false
      }
      vim.keymap.set('n', '<Leader>ah', function () vim.cmd('HighlightColorsToggle') end)
      vim.api.nvim_create_autocmd({ 'ColorScheme' }, {
        pattern = '*',
        callback = function () vim.cmd('HighlightColorsOn') end
      })
    end
  }

@wookayin I would like to know about your choice between that maintained fork and this one I'm using. (I found the latter after my last reply. It currently has some trouble regarding large files)

update: Oh sorry, I must be blind in that it is clearly documented there and I didn't see it.

Just to clarify, my plugin (nvim-highlight-colors) is not a fork, I built it from scratch 😄

@brenoprata10 No worries, I meant NvChad one when I wrote "that maintained fork".