From bb951669d469f03981028b1c45df2ee3cb040d2b Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 20 Apr 2021 23:57:15 +0200 Subject: [PATCH] fix: delete autocmds when the colorscheme changes to something else --- lua/tokyonight/util.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lua/tokyonight/util.lua b/lua/tokyonight/util.lua index 642e0e3..a94b49b 100644 --- a/lua/tokyonight/util.lua +++ b/lua/tokyonight/util.lua @@ -59,10 +59,19 @@ function util.debug(colors) end end +--- Delete the autocmds when the theme changes to something else +function util.onColorScheme() + if vim.g.colors_name ~= "tokyonight" then + vim.cmd [[autocmd! TokyoNight]] + vim.cmd [[augroup! TokyoNight]] + end +end + ---@param config Config function util.autocmds(config) vim.cmd [[augroup TokyoNight]] vim.cmd [[ autocmd!]] + vim.cmd [[ autocmd ColorScheme * lua require("tokyonight.util").onColorScheme()]] if config.dev then vim.cmd [[ autocmd BufWritePost */lua/tokyonight/** nested colorscheme tokyonight]] end