From f53bde671198b99e84ca4f9783a50f5c4b07bd68 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Sat, 3 Sep 2022 18:07:07 +0530 Subject: colorizer: Fix an edgecase when colorizer is enabled for buftype but disabled for filetype it should remain disabled if any --- lua/colorizer.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/colorizer.lua b/lua/colorizer.lua index 87acad3..13d0b43 100644 --- a/lua/colorizer.lua +++ b/lua/colorizer.lua @@ -301,7 +301,14 @@ local function setup(config) local function COLORIZER_SETUP_HOOK(typ) local filetype = vim.bo.filetype local buftype = vim.bo.buftype + local buf = current_buf() if SETUP_SETTINGS.exclusions.file[filetype] or SETUP_SETTINGS.exclusions.buf[buftype] then + -- when a filetype is disabled but buftype is enabled, it can Attach in + -- some cases, so manually detach + if BUFFER_OPTIONS[buf] then + detach_from_buffer(buf) + end + BUFFER_INIT[buf] = nil return end @@ -324,7 +331,6 @@ local function setup(config) -- this should ideally be triggered one time per buffer -- but BufWinEnter also triggers for split formation -- but we don't want that so add a check using local buffer variable - local buf = current_buf() if not BUFFER_INIT[buf] then attach_to_buffer(buf, options, typ) end -- cgit v1.2.3-70-g09d2