yetone / avante.nvim

Use your Neovim like using Cursor AI IDE!
Apache License 2.0
7.27k stars 270 forks source link

bug: highlights removed after changing colorscheme #654

Open gravityblast opened 1 month ago

gravityblast commented 1 month ago

Describe the bug

If I change the colorscheme during a session, or if the colorscheme is applied by a plugin loaded after avante, the highlights in the titles are not set.

To reproduce

Change colorscheme during a session

Expected behavior

The highlights in the titles should remain.

I notice that it works changing

api.nvim_create_autocmd("ColorSchemePre", {

to

api.nvim_create_autocmd("ColorScheme", {

Is ColorSchemePre used on purpose for other reasons?

Environment

NVIM v0.10.0 Build type: Release LuaJIT 2.1.1713773202

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    -- add any other plugins here
  },
})
aarnphm commented 1 month ago

Reasoning: https://neovim.io/doc/user/autocmd.html#ColorSchemePre

srgsanky commented 1 month ago

+1, I had to use the following workaround

      -- Highlight groups have to be reinitialized after setting the color scheme
      -- <https://github.com/yetone/avante.nvim/issues/654>
      vim.api.nvim_create_autocmd('ColorScheme', {
        callback = function()
          require('avante.highlights').setup()
        end,
      })