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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
2f0a498b43
commit
94ee311b25
@@ -1,6 +1,6 @@
|
||||
# Maintainer: Ryan Hughes <ryan@omarchy.org>
|
||||
pkgname=omarchy-nvim
|
||||
pkgver=2026.7.15
|
||||
pkgver=2026.7.16
|
||||
pkgrel=1
|
||||
pkgdesc="Pre-built LazyVim configuration with cached plugins"
|
||||
arch=('any')
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user