From 125ced99e801ba9af288602166b240e8915133b5 Mon Sep 17 00:00:00 2001 From: Harry Gallagher Date: Mon, 29 Mar 2021 18:30:59 -0500 Subject: [PATCH 1/3] add "both" mode that highlights foreground and background --- lua/colorizer.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/colorizer.lua b/lua/colorizer.lua index e47e079..8667fb3 100644 --- a/lua/colorizer.lua +++ b/lua/colorizer.lua @@ -63,7 +63,7 @@ local DEFAULT_OPTIONS = { hsl_fn = false; -- CSS hsl() and hsla() functions css = false; -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB css_fn = false; -- Enable all CSS *functions*: rgb_fn, hsl_fn - -- Available modes: foreground, background + -- Available modes: foreground, background, both mode = 'background'; -- Set the display mode. } @@ -328,6 +328,7 @@ local HIGHLIGHT_NAME_PREFIX = "colorizer" local HIGHLIGHT_MODE_NAMES = { background = "mb"; foreground = "mf"; + both = "mbf"; } local HIGHLIGHT_CACHE = {} @@ -355,6 +356,8 @@ local function create_highlight(rgb_hex, options) highlight_name = make_highlight_name(rgb_hex, mode) if mode == 'foreground' then nvim.ex.highlight(highlight_name, "guifg=#"..rgb_hex) + elseif mode == 'both' then + nvim.ex.highlight(highlight_name, "guifg=#"..rgb_hex, "guibg=#"..rgb_hex) else local r, g, b = rgb_hex:sub(1,2), rgb_hex:sub(3,4), rgb_hex:sub(5,6) r, g, b = tonumber(r,16), tonumber(g,16), tonumber(b,16) @@ -560,7 +563,7 @@ end -- Possible options: -- - `no_names`: Don't highlight names like Blue -- - `rgb_fn`: Highlight `rgb(...)` functions. --- - `mode`: Highlight mode. Valid options: `foreground`,`background` +-- - `mode`: Highlight mode. Valid options: `foreground`,`background`,`both` -- -- @param[opt={'*'}] filetypes A table/array of filetypes to selectively enable and/or customize. By default, enables all filetypes. -- @tparam[opt] {[string]=string} default_options Default options to apply for the filetypes enable. From 4a843f8dedf5f74f532506a45d964a6993d462ea Mon Sep 17 00:00:00 2001 From: Harry Gallagher Date: Mon, 29 Mar 2021 18:39:01 -0500 Subject: [PATCH 2/3] fix formatting --- lua/colorizer.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/colorizer.lua b/lua/colorizer.lua index 8667fb3..c105290 100644 --- a/lua/colorizer.lua +++ b/lua/colorizer.lua @@ -356,7 +356,7 @@ local function create_highlight(rgb_hex, options) highlight_name = make_highlight_name(rgb_hex, mode) if mode == 'foreground' then nvim.ex.highlight(highlight_name, "guifg=#"..rgb_hex) - elseif mode == 'both' then + elseif mode == 'both' then nvim.ex.highlight(highlight_name, "guifg=#"..rgb_hex, "guibg=#"..rgb_hex) else local r, g, b = rgb_hex:sub(1,2), rgb_hex:sub(3,4), rgb_hex:sub(5,6) From f5e094d0557aac1063e042c24fd5f3121133578b Mon Sep 17 00:00:00 2001 From: Harry Gallagher Date: Mon, 29 Mar 2021 18:46:21 -0500 Subject: [PATCH 3/3] fix formatting... again --- lua/colorizer.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/colorizer.lua b/lua/colorizer.lua index c105290..cfaf124 100644 --- a/lua/colorizer.lua +++ b/lua/colorizer.lua @@ -328,7 +328,7 @@ local HIGHLIGHT_NAME_PREFIX = "colorizer" local HIGHLIGHT_MODE_NAMES = { background = "mb"; foreground = "mf"; - both = "mbf"; + both = "mbf"; } local HIGHLIGHT_CACHE = {}