From 795a7c82fcbc889645799c7b3b34b247acdcc18d Mon Sep 17 00:00:00 2001 From: "Sindre T. Strøm" Date: Wed, 4 May 2022 13:22:57 +0200 Subject: fix: Clear the highlight cache on 'ColorScheme' event. --- lua/colorizer.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/colorizer.lua b/lua/colorizer.lua index f24c792..becc3e2 100644 --- a/lua/colorizer.lua +++ b/lua/colorizer.lua @@ -776,6 +776,7 @@ local function setup(filetypes, user_default_options) end end end + nvim.ex.autocmd("ColorScheme", "*", "lua require('colorizer').clear_highlight_cache()") nvim.ex.augroup "END" end @@ -786,6 +787,12 @@ local function reload_all_buffers() end end +--- Clear the highlight cache and reload all buffers. +local function clear_highlight_cache() + HIGHLIGHT_CACHE = {} + vim.schedule(reload_all_buffers) +end + --- Return the currently active buffer options. -- @tparam[opt=0|nil] integer buf A value of 0 or nil implies the current buffer. local function get_buffer_options(buf) @@ -805,4 +812,5 @@ return { highlight_buffer = highlight_buffer, reload_all_buffers = reload_all_buffers, get_buffer_options = get_buffer_options, + clear_highlight_cache = clear_highlight_cache, } -- cgit v1.2.3-70-g09d2