Skip to content

bug: Normal highlight slightly different just after running :Lazy build #753

@Iron-E

Description

@Iron-E

Did you check docs and existing issues?

  • I have read all the lazy.nvim docs
  • I have searched the existing issues of lazy.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.9.0

Operating system/version

6.2.12-arch1-1

Describe the bug

It seems the color of Normal is modified temporarily after executing :Lazy build. For example:

  • in my personal colorscheme, Normal's background color is "#202020". During :Lazy build, it is "#353535"
  • in the default colorscheme, Normal is cleared. During :Lazy build, the background "#ff00ff"

Steps To Reproduce

  1. Add a build hook to any plugin, e.g.:
    {'folke/lazy.nvim', tag = 'stable', build = function()
        vim.print(vim.g.colors_name, vim.api.nvim_get_hl(0, {name = 'Normal', link = false}))
        vim.defer_fn(function() vim.print(vim.g.colors_name, vim.api.nvim_get_hl(0, {name = 'Normal', link = false})) end, 5000)
    end},
  2. Start nvim, then run :hi Normal to verify the correct Normal highlight color.
  3. :Lazy build <plugin>, it will print an incorrect Normal color first then 5 seconds later it will print the correct one.

Expected Behavior

The Normal highlight group should remain unmodified while running :Lazy build, so that colorscheme plugins (e.g. mini.colors) can run update hooks.

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 = {
  {"folke/tokyonight.nvim", build = function()
    vim.cmd.colorscheme("tokyonight")
    vim.print(vim.g.colors_name, vim.api.nvim_get_hl(0, {name = 'Normal', link = false}))
    vim.defer_fn(function() vim.print(vim.g.colors_name, vim.api.nvim_get_hl(0, {name = 'Normal', link = false})) end, 5000)
  end},
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions