From e30547be04fdb64382eb626ec5e9f0eda54f6bef Mon Sep 17 00:00:00 2001 From: aileot <46470475+aileot@users.noreply.github.com> Date: Fri, 20 Jun 2025 06:01:56 +0900 Subject: [PATCH 1/2] fix(autocmd): invoke ColorScheme{Pre,} events Typically, to let per-colorscheme modification take effect like overriding `hl-MatchParen` attributes. --- lua/styler/theme.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/styler/theme.lua b/lua/styler/theme.lua index bd72de4..d650b1f 100644 --- a/lua/styler/theme.lua +++ b/lua/styler/theme.lua @@ -26,7 +26,9 @@ function M.load(theme) self.orig = M.get_current() self.theme = theme self:before() + vim.api.nvim_exec_autocmds("ColorSchemePre", { pattern = self.theme.colorscheme }) vim.cmd("colorscheme " .. self.theme.colorscheme) + vim.api.nvim_exec_autocmds("ColorScheme", { pattern = self.theme.colorscheme }) self:after() end return ns @@ -36,8 +38,9 @@ function M:before() pcall(function() require("lazy.core.loader").colorscheme(self.theme.colorscheme) end) + self.last_eventignore = vim.go.eventignore -- don't trigger autocmds - vim.go.eventignore = "all" + vim.go.eventignore = "all,-ColorSchemePre,-ColorScheme" -- set to nil, so most themes won't run `hi clear` to prevent flickering vim.g.colors_name = nil @@ -79,7 +82,7 @@ function M:after() end -- enable autocmds - vim.go.eventignore = "" + vim.go.eventignore = self.last_eventignore -- schedule theme reload vim.schedule(function() From f2561db6387864b7f309a7edaa69b3a6df752704 Mon Sep 17 00:00:00 2001 From: aileot <46470475+aileot@users.noreply.github.com> Date: Thu, 18 Sep 2025 23:51:53 +0900 Subject: [PATCH 2/2] fix: exclude ColorScheme events only on >=0.12 The `-` prefixed eventignore syntax is not supported on <0.12. --- lua/styler/theme.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/styler/theme.lua b/lua/styler/theme.lua index d650b1f..80c1f5e 100644 --- a/lua/styler/theme.lua +++ b/lua/styler/theme.lua @@ -40,7 +40,11 @@ function M:before() end) self.last_eventignore = vim.go.eventignore -- don't trigger autocmds - vim.go.eventignore = "all,-ColorSchemePre,-ColorScheme" + if vim.fn.has('nvim-0.12') == 1 then + vim.go.eventignore = "all,-ColorSchemePre,-ColorScheme" + else + vim.go.eventignore = "all" + end -- set to nil, so most themes won't run `hi clear` to prevent flickering vim.g.colors_name = nil