aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSindre T. Strøm <sindrets@gmail.com>2022-05-04 13:22:57 +0200
committerSindre T. Strøm <sindrets@gmail.com>2022-08-07 13:16:16 +0200
commit795a7c82fcbc889645799c7b3b34b247acdcc18d (patch)
tree022f2b2178643b4c690b26d283f385df35024d97
parentMerge pull request #7 from sitiom/patch-1 (diff)
fix: Clear the highlight cache on 'ColorScheme' event.
-rw-r--r--lua/colorizer.lua8
1 files changed, 8 insertions, 0 deletions
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,
}