NvChad / nvim-colorizer.lua

Maintained fork of the fastest Neovim colorizer
Other
708 stars 47 forks source link

Bug:not working in lazy.nvim #62

Closed xclidongbo closed 1 year ago

xclidongbo commented 1 year ago
  {
    "NvChad/nvim-colorizer.lua",
    config = function()
      require("colorizer").setup()
    end,
  },
sscherfke commented 1 year ago

For me it works this way:

 {
    "NvChad/nvim-colorizer.lua",
    -- event = "VeryLazy",  -- https://github.com/NvChad/nvim-colorizer.lua/issues/57
    -- event = { "BufReadPost", "BufNewFile" },
    opts = {
      user_default_options = {
        mode = "virtualtext",
        names = false,
      },
      filetypes = {
        "*",
        css = { names = true, css = true, css_fn = true },
      },
    },
  },

I have currently disabled event b/c of #57.

louis-vinchon commented 1 year ago

@xclidongbo You should generally define the opts key even if it's empty ({}), some plugins like mini simply won't work without it.

You don't need to define config here, the default behavior of Lazy is to setup() the plugin. Some plugins also don't like being setup() without a table as argument setup({}).

Lazy documentation.

My working conf:

-- https://github.com/NvChad/nvim-colorizer.lua

local opts = {
  filetypes = {
    "*",

    -- Excluded filteypes.
    "!lazy", -- Commit hashes get highlighted sometimes.
  },
  user_default_options = {
    RGB = true, -- #RGB hex codes.
    RRGGBB = true, -- #RRGGBB hex codes.
    RRGGBBAA = true, -- #RRGGBBAA hex codes.
    AARRGGBB = true, -- 0xAARRGGBB hex codes.

    -- "Name" codes like Blue or blue. It is pretty annoying when you have maps with
    -- 'blue = color_hex': you get two previews, one for the key and one for the value.
    names = false, 

    rgb_fn = true, -- CSS rgb() and rgba() functions.
    hsl_fn = true, -- CSS hsl() and hsla() functions.
    css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB.
    css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn.
    tailwind = true,

    mode = "virtualtext",
    virtualtext = "■",
  },
}

return {
  "NvChad/nvim-colorizer.lua",
  event = { "BufReadPost", "BufNewFile" },
  opts = opts,
}
TiLopes commented 1 year ago

@louis-vinchon I'm currently using your config but it seems tailwind is not working as I get no colors higlighting.

My code:

const CondominioLayout: Component<{}> = () => {
  return (
    <div class="flex w-full flex-col self-stretch">
      <nav class="bg-blue-600 p-4 text-white">
        <ul class="flex items-center">
          <A href="perfil" class="mr-6 flex items-center gap-2">
            <i class="i-ph-user-fill"></i>
            Perfil
          </A>
          <li class="mx-6">ASDASASD</li>
          <li class="mx-6">ASDASASD</li>
          <li class="mx-6">ASDASASD</li>
          <li class="mx-6">ASDASASD</li>
          <li class="mx-6">ASDASASD</li>
          <li class="mx-6">ASDASASD</li>
        </ul>
      </nav>
      <main class="flex w-full self-stretch flex-grow">
        <Outlet />
      </main>
    </div>
  );
};

LspInfo (if that matters): image

Myzel394 commented 8 months ago

I'm facing the same issue as @TiLopes; did you find a solution?