From fff9897ce3f246add656ebf28bbcc843900431f1 Mon Sep 17 00:00:00 2001 From: Puneet Dixit Date: Sun, 17 May 2026 21:48:24 +0530 Subject: fix(startup): emitting useless OptionSet #39830 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: During startup, we manually trigger a useless and misleading `OptionSet` event, which doesn't set `v:option_*` values (this is a limitation of `nvim_exec_autocmds`). https://github.com/neovim/neovim/blob/ad4bc2d90c5109c24bf6f0119ad31276f1518c6f/runtime/lua/vim/_core/defaults.lua#L939. Solution: The `nvim_exec_autocmds('OptionSet',…)` call does not serve any purpose since 5cbb9d613bf6d8983b5effd7e20343a4ef497c06, so just drop it. --- runtime/lua/vim/_core/defaults.lua | 14 -------------- runtime/lua/vim/_meta/options.gen.lua | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/_core/defaults.lua b/runtime/lua/vim/_core/defaults.lua index 31bc56a4db..4490d315af 100644 --- a/runtime/lua/vim/_core/defaults.lua +++ b/runtime/lua/vim/_core/defaults.lua @@ -946,20 +946,6 @@ do local luminance = (0.299 * rr) + (0.587 * gg) + (0.114 * bb) local bg = luminance < 0.5 and 'dark' or 'light' vim.api.nvim_set_option_value('background', bg, {}) - - -- Ensure OptionSet still triggers when we set the background during startup - if vim.v.vim_did_enter == 0 then - vim.api.nvim_create_autocmd('VimEnter', { - group = group, - once = true, - nested = true, - callback = function() - vim.api.nvim_exec_autocmds('OptionSet', { - pattern = 'background', - }) - end, - }) - end end end end) diff --git a/runtime/lua/vim/_meta/options.gen.lua b/runtime/lua/vim/_meta/options.gen.lua index 32f31bfdf7..9bba00501d 100644 --- a/runtime/lua/vim/_meta/options.gen.lua +++ b/runtime/lua/vim/_meta/options.gen.lua @@ -224,7 +224,7 @@ vim.go.awa = vim.go.autowriteall --- When set to "dark" or "light", adjusts the default color groups for --- that background type. The `TUI` or other UI sets this on startup ---- (triggering `OptionSet`) if it can detect the background color. +--- if it can detect the background color. --- --- This option does NOT change the background color, it tells Nvim what --- the "inherited" (terminal/GUI) background looks like. -- cgit