Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: CSS variables not rendering #92

Open
rodhash opened this issue Nov 9, 2024 · 0 comments
Open

Bug: CSS variables not rendering #92

rodhash opened this issue Nov 9, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@rodhash
Copy link

rodhash commented Nov 9, 2024

Describe the bug
CSS colors not rendered when using variables

image

To Reproduce

  1. Open a CSS file with below minimal
  2. It works in most situations but not on CSS variables

Minimal:

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/noice.nvim",
  -- add any other plugins here
  "nvim-neo-tree/neo-tree.nvim",
  "nvim-lua/plenary.nvim",
  "rodhash/nvim-web-devicons",
  "MunifTanjim/nui.nvim",
  "rcarriga/nvim-notify",
  "nvim-lua/plenary.nvim",
  "nvim-treesitter/nvim-treesitter",
  "ray-x/lsp_signature.nvim",

  -- LSP
  "neovim/nvim-lspconfig",
  "williamboman/mason.nvim",
  "williamboman/mason-lspconfig.nvim",

  -- Completion
  "hrsh7th/nvim-cmp",
  "hrsh7th/cmp-nvim-lsp",
  "hrsh7th/nvim-cmp",
  "hrsh7th/cmp-buffer",

  -- vsnip
  "hrsh7th/cmp-vsnip",
  "hrsh7th/vim-vsnip",

  -- others
  'NvChad/nvim-colorizer.lua',
  'onsails/lspkind.nvim',
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

local nvim_set_hl = vim.api.nvim_set_hl

require("noice").setup({
  lsp = {
    signature = {
      enabled = false,
    },
  }}
)

require("mason").setup()
require("mason-lspconfig").setup {
    ensure_installed = { "cssls", "tailwindcss" },
}
require'lsp_signature'.setup() -- no need to specify bufnr if you don't use toggle_key

-- CMP

  -- Set up nvim-cmp.
  local cmp = require'cmp'

    cmp.setup({
      formatting = {
              format = function(entry, item)
                      local color_item = require("nvim-highlight-colors").format(entry, { kind = item.kind })
                      item = require("lspkind").cmp_format({
                              -- any lspkind format settings here
                      })(entry, item)
                      if color_item.abbr_hl_group then
                              item.kind_hl_group = color_item.abbr_hl_group
                              item.kind = color_item.abbr
                      end
                      return item
              end
      },

      snippet = {
        -- REQUIRED - you must specify a snippet engine
        expand = function(args)
          vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
          -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
          -- require('snippy').expand_snippet(args.body) -- For `snippy` users.
          -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
        end,
      },
      window = {
        completion = cmp.config.window.bordered(),
        documentation = cmp.config.window.bordered(),
      },
      mapping = cmp.mapping.preset.insert({
        ['<C-b>'] = cmp.mapping.scroll_docs(-4),
        ['<C-f>'] = cmp.mapping.scroll_docs(4),
        ['<C-Space>'] = cmp.mapping.complete(),
        ['<C-e>'] = cmp.mapping.abort(),
        ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
        ['<C-h>'] = function() cmp.complete() end,
      }),
      sources = cmp.config.sources({
        { name = 'nvim_lsp' },
        { name = 'vsnip' },
        { name = "buffer" },
        -- { name = 'luasnip' }, -- For luasnip users.
        -- { name = 'ultisnips' }, -- For ultisnips users.
        -- { name = 'snippy' }, -- For snippy users.
      })
    })


  -- Set up lspconfig.
  local capabilities = require('cmp_nvim_lsp').default_capabilities()
  capabilities.textDocument.completion.completionItem.snippetSupport = true
  capabilities.offsetEncoding = { "utf-16" }

  require('lspconfig')['cssls'].setup {
    capabilities = capabilities
  }

  require("colorizer").setup {
    -- filetypes = { "*" },
    filetypes = {'*'},
    buftypes = { "*" },
    cmp_docs = { always_update = true },
    cmp_menu = { always_update = true },
    user_default_options = {
      RGB      = true, -- #RGB hex codes
      RRGGBB   = true, -- #RRGGBB hex codes
      names    = true, -- "Name" codes like Blue or blue
      RRGGBBAA = true, -- #RRGGBBAA hex codes
      AARRGGBB = true, -- 0xAARRGGBB hex codes
      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
      -- Available modes for `mode`: foreground, background,  virtualtext
      mode     = "background", -- Set the display mode.
      -- Available methods are false / true / "normal" / "lsp" / "both"
      -- True is same as normal
      tailwind = true, -- Enable tailwind colors
      -- parsers can contain values used in |user_default_options|
      sass = { enable = true, parsers = { "css" }, }, -- Enable sass colors
      -- update color values even if buffer is not focused
      -- example use: cmp_menu, cmp_docs
      always_update = true
    },
    -- all the sub-options of filetypes apply to buftypes
    -- buftypes = { "*" },
  }

Expected behavior
To have CSS variables highlight working similarly to what we have when we define the colors:
image

Screenshots
Today it's not working for CSS var:
image

Operating System:
Mac Sequoia 15.1

Neovim Version:
NVIM v0.11.0-dev-1028+g6dad1f9f1

Colorizer Version:
find ~/.config/nvim/ -type d -name 'nvim-colorizer.lua' -exec git rev-parse HEAD \;
010669804774fb2bd4b25d501e26346fe8218192

@rodhash rodhash added the bug Something isn't working label Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants