This is a real situation as I have a function that updates colorscheme based on a global variable:
local update = function()
-- Based on my measurements on MacBook Air M2, this function takes 0.2 ms
-- w/o colorscheme change, and 4ms when a colorscheme change happens.
local f = io.open("/Users/grzesiek/.config/fish/BACKGROUND.variable", "r")
if not f then
return nil
end
local contents = f:read("*a")
f:close()
if vim.o.background == "light" and contents.find(contents, "dark") then
vim.o.background = "dark"
vim.cmd("colorscheme gruvbox-flat")
elseif vim.o.background == "dark" and contents.find(contents, "light") then
vim.o.background = "light"
vim.cmd("colorscheme gruvbox-material")
end
end
The background change followed by colorscheme generates two ColorScheme events.
The deferred colorscheme update in https://github.com/eddyekofo94/gruvbox-flat.nvim/blame/172269867994c0da7adcf02e89a068cda85eb805/lua/gruvbox/util.lua#L206 can cause gruvbox-flat to override other colorscheme if two
ColorScheme
events happen next to each other.This is a real situation as I have a function that updates colorscheme based on a global variable:
The background change followed by colorscheme generates two
ColorScheme
events.Could we just delete the deferred update?