From a6cae467b7cd24f1e98be8098ac156f76c0e4f13 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Sat, 13 Jan 2024 05:51:40 -0600 Subject: feat: add RGB colorizer support --- lua/plugins/colorizer.lua | 35 +++++++++++++++++++++++++++++++++++ lua/plugins/hl-mdcodeblock.lua | 20 ++++++++++---------- 2 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 lua/plugins/colorizer.lua diff --git a/lua/plugins/colorizer.lua b/lua/plugins/colorizer.lua new file mode 100644 index 0000000..f676278 --- /dev/null +++ b/lua/plugins/colorizer.lua @@ -0,0 +1,35 @@ +return { + 'NvChad/nvim-colorizer.lua', + opts = { + filetypes = { '*' }, + user_default_options = { + RGB = true, -- #RGB hex codes + RRGGBB = true, -- #RRGGBB hex codes + names = true, -- "Name" codes like Blue or blue + RRGGBBAA = false, -- #RRGGBBAA hex codes + AARRGGBB = false, -- 0xAARRGGBB hex codes + rgb_fn = false, -- CSS rgb() and rgba() functions + 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 for `mode`: foreground, background, virtualtext + mode = 'background', -- Set the display mode. + -- Available methods are false / true / "normal" / "lsp" / "both" + -- True is same as normal + tailwind = false, -- Enable tailwind colors + -- parsers can contain values used in |user_default_options| + sass = { enable = false, parsers = { 'css' }, }, -- Enable sass colors + virtualtext = '■', + -- update color values even if buffer is not focused + -- example use: cmp_menu, cmp_docs + always_update = false, + }, + -- all the sub-options of filetypes apply to buftypes + buftypes = {}, + }, + config = function(_, opts) + require('colorizer').setup(opts) + + vim.keymap.set('n', 'ct', 'ColorizerToggle', { desc = '[C]olorizer [T]oggle' }) + end +} diff --git a/lua/plugins/hl-mdcodeblock.lua b/lua/plugins/hl-mdcodeblock.lua index 3221678..b7bd7f3 100644 --- a/lua/plugins/hl-mdcodeblock.lua +++ b/lua/plugins/hl-mdcodeblock.lua @@ -3,8 +3,8 @@ return { dependencies = { 'nvim-treesitter/nvim-treesitter' }, config = function() require('hl-mdcodeblock').setup({ - hl_group = "MDCodeBlock", -- default highlight group - events = { -- refresh event + hl_group = "MDCodeBlock", -- default highlight group + events = { -- refresh event "FileChangedShellPost", "Syntax", "TextChanged", @@ -13,19 +13,19 @@ return { "WinScrolled", "BufEnter", }, - padding_right = 4, -- always append 4 space at lineend - timer_delay = 20, -- refresh delay(ms) - query_by_ft = { -- special parser query by filetype - markdown = { -- filetype - 'markdown', -- parser + padding_right = 4, -- always append 4 space at lineend + timer_delay = 20, -- refresh delay(ms) + query_by_ft = { -- special parser query by filetype + markdown = { -- filetype + 'markdown', -- parser '(fenced_code_block) @codeblock', -- query }, - rmd = { -- filetype - 'markdown', -- parser + rmd = { -- filetype + 'markdown', -- parser '(fenced_code_block) @codeblock', -- query }, }, - minumum_len = 100, -- minimum len to highlight (number | function) + minumum_len = 100, -- minimum len to highlight (number | function) -- minumum_len = function () return math.max(math.floor(vim.api.nvim_win_get_width(0) * 0.8), 100) end }) end, -- cgit v1.2.3-70-g09d2