catppuccin / nvim

🍨 Soothing pastel theme for (Neo)vim
MIT License
5.25k stars 235 forks source link

836de8b breaks using LSP colors in the custom_highlights #669

Closed milch closed 1 month ago

milch commented 5 months ago

Description

I have some custom highlights set up in my config like this:

    custom_highlights = function()
        local lsp = require("catppuccin.groups.integrations.native_lsp").get()
        return {
            Group1 = { fg = lsp.DiagnosticVirtualTextError.fg, bg = lsp.DiagnosticVirtualTextError.bg },
                        -- ... etc. ...
        }
    end,

It seems that this broke with the following commit: https://github.com/catppuccin/nvim/commit/836de8bc1898250b69332e66cbe993058870f849, and now I get the following error when catppuccin loads:

Failed to run `config` for catppuccin
...puccin/lua/catppuccin/groups/integrations/native_lsp.lua:4: attempt to index global 'O' (a nil value)
# stacktrace:
  - /catppuccin/lua/catppuccin/groups/integrations/native_lsp.lua:4 _in_ **get**
  - ~/.config/nvim/lua/ui/catppuccin.lua:27 _in_ **v**
  - /catppuccin/lua/catppuccin/lib/hashing.lua:21 _in_ **hash**
  - /catppuccin/lua/catppuccin/lib/hashing.lua:17 _in_ **hash**
  - /catppuccin/lua/catppuccin/init.lua:169 _in_ **setup**

Neovim version

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1703358377

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.9.5/share/nvim"

Run :checkhealth for more info

Terminal and multiplexer

wezterm 20240203-110809-5046fc22 with tmux next-3.4

Catppuccin version / branch / rev

See above

Steps to reproduce

  1. nvim -u repro.lua
  2. It fails on load

Expected behavior

I should be able to use LSP colors in the custom highlights group

Actual behavior

Error on load:

Failed to run `config` for catppuccin
...puccin/lua/catppuccin/groups/integrations/native_lsp.lua:4: attempt to index global 'O' (a nil value)
# stacktrace:
  - /catppuccin/lua/catppuccin/groups/integrations/native_lsp.lua:4 _in_ **get**
  - ~/.config/nvim/lua/ui/catppuccin.lua:27 _in_ **v**
  - /catppuccin/lua/catppuccin/lib/hashing.lua:21 _in_ **hash**
  - /catppuccin/lua/catppuccin/lib/hashing.lua:17 _in_ **hash**
  - /catppuccin/lua/catppuccin/init.lua:169 _in_ **setup**

Repro

-- 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 = {
    {
        "catppuccin/nvim",
        name = "catppuccin",
        commit = "836de8bc1898250b69332e66cbe993058870f849",
        opts = {
            integrations = {
                custom_highlights = function()
                    local lsp = require("catppuccin.groups.integrations.native_lsp").get()
                    return {
                        MyHighlightGroup = {
                            fg = lsp.DiagnosticVirtualTextError.fg,
                            bg = lsp.DiagnosticVirtualTextError.bg,
                        },
                    }
                end,
            },
        },
    },
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd.colorscheme("catppuccin")
mrtnvgr commented 5 months ago

Take a look at #667 🙂

vollowx commented 1 month ago

Closed due to inactivity, feel free to re-open if you need to :heart: .