From 94ee311b250cc56fd22de36f1e3e45f0e9c8413f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 19 Jul 2026 20:34:22 -0700 Subject: [PATCH] Fix theme hot-reload when old and new theme share the same colorscheme plugin lazy.nvim caches a plugin's resolved opts in plugin._.cache and carries that state over on a spec reload, and Loader.colorscheme() no-ops for already-loaded plugins. So switching between two themes driven by the same colorscheme plugin (e.g. generic themes on aether.nvim) never pushed the new palette into setup(), leaving stale colors until nvim was restarted. Fully reload the theme plugin instead, which clears the cached opts and reruns config with the new theme's colors. Co-Authored-By: Claude Fable 5 --- pkgbuilds/omarchy-nvim/PKGBUILD | 2 +- .../lua/plugins/omarchy-theme-hotreload.lua | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pkgbuilds/omarchy-nvim/PKGBUILD b/pkgbuilds/omarchy-nvim/PKGBUILD index d1d763e..4e0ef79 100644 --- a/pkgbuilds/omarchy-nvim/PKGBUILD +++ b/pkgbuilds/omarchy-nvim/PKGBUILD @@ -1,6 +1,6 @@ # Maintainer: Ryan Hughes pkgname=omarchy-nvim -pkgver=2026.7.15 +pkgver=2026.7.16 pkgrel=1 pkgdesc="Pre-built LazyVim configuration with cached plugins" arch=('any') diff --git a/pkgbuilds/omarchy-nvim/lua/plugins/omarchy-theme-hotreload.lua b/pkgbuilds/omarchy-nvim/lua/plugins/omarchy-theme-hotreload.lua index 054ff29..ec49378 100644 --- a/pkgbuilds/omarchy-nvim/lua/plugins/omarchy-theme-hotreload.lua +++ b/pkgbuilds/omarchy-nvim/lua/plugins/omarchy-theme-hotreload.lua @@ -55,8 +55,17 @@ return { if spec[1] == "LazyVim/LazyVim" and spec.opts and spec.opts.colorscheme then local colorscheme = spec.opts.colorscheme - -- Load the colorscheme plugin - require("lazy.core.loader").colorscheme(colorscheme) + -- Load the colorscheme plugin. If it's already loaded (old and new + -- theme sharing the same plugin, e.g. generic themes on aether.nvim), + -- lazy won't rerun setup() on a spec reload and keeps the old + -- resolved opts in the plugin's property cache, so fully reload it + -- to reapply setup() with the new theme's opts. + local theme_plugin = theme_plugin_name and require("lazy.core.config").plugins[theme_plugin_name] + if theme_plugin and theme_plugin._.loaded then + require("lazy.core.loader").reload(theme_plugin) + else + require("lazy.core.loader").colorscheme(colorscheme) + end vim.defer_fn(function() -- Apply the colorscheme (it will set background itself)