From f661199197cc1346124b0b12e77f25150c50a776 Mon Sep 17 00:00:00 2001 From: Ashkan Kiani Date: Fri, 18 Oct 2019 09:56:49 -0700 Subject: Allow excluding files from highlight with '*' (#11) Fixes GH-5 --- lua/colorizer.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lua/colorizer.lua') diff --git a/lua/colorizer.lua b/lua/colorizer.lua index b869897..32717e5 100644 --- a/lua/colorizer.lua +++ b/lua/colorizer.lua @@ -292,6 +292,9 @@ local function setup(filetypes, default_options) default_options = SETUP_SETTINGS.default_options function COLORIZER_SETUP_HOOK() local filetype = nvim.bo.filetype + if SETUP_SETTINGS.exclusions[filetype] then + return + end local options = FILETYPE_OPTIONS[filetype] or SETUP_SETTINGS.default_options attach_to_buffer(nvim_get_current_buf(), options) end @@ -315,9 +318,14 @@ local function setup(filetypes, default_options) else filetype = v end - FILETYPE_OPTIONS[filetype] = options - -- TODO What's the right mode for this? BufEnter? - nvim.ex.autocmd("FileType", filetype, "lua COLORIZER_SETUP_HOOK()") + -- Exclude + if filetype:sub(1,1) == '!' then + SETUP_SETTINGS.exclusions[filetype:sub(2)] = true + else + FILETYPE_OPTIONS[filetype] = options + -- TODO What's the right mode for this? BufEnter? + nvim.ex.autocmd("FileType", filetype, "lua COLORIZER_SETUP_HOOK()") + end end end nvim.ex.augroup("END") -- cgit v1.2.3-70-g09d2