From 5f7680e7e7ccad68bd9962bcbb40dfde1c3669a1 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Sun, 4 Sep 2022 18:32:02 +0530 Subject: Fix https://github.com/NvChad/nvim-colorizer.lua/issues/12 | Add support for tailwind colors Three methods normal: Use the hardcoded colors lsp: Use lsp to fetch colors both: Use the hardcoded colors and use lsp too if available although this is hardcoding, but working with what we got, has all the colors tailwind provides, atleast the prebuilt ones for new defined colors, have to enable the lsp method Generated using https://github.com/tailwindlabs/tailwindcss/raw/master/src/public/colors.js and https://github.com/tailwindlabs/tailwindcss/raw/master/src/corePlugins.js use a different namespace than default for tailwind lsp method only try to use lsp method if attached Misc changes export the user_default_settings to doc clear name space after the lines are processed for a smooth transition cleanup some code --- doc/colorizer.txt | 105 ++++++++++++++++++++--------- doc/index.html | 2 +- doc/ldoc_vim.ltp | 5 +- doc/modules/colorizer.buffer_utils.html | 26 ++++++-- doc/modules/colorizer.color_utils.html | 9 ++- doc/modules/colorizer.html | 109 ++++++++++++++++++++++++++----- doc/modules/colorizer.matcher_utils.html | 2 +- doc/modules/colorizer.trie.html | 2 +- doc/modules/utils.html | 2 +- doc/tags | 1 + 10 files changed, 199 insertions(+), 64 deletions(-) (limited to 'doc') diff --git a/doc/colorizer.txt b/doc/colorizer.txt index 1480756..5ac2abc 100644 --- a/doc/colorizer.txt +++ b/doc/colorizer.txt @@ -85,6 +85,9 @@ Functions: ~ |clear_highlight_cache| - Clear the highlight cache and reload all buffers. +Tables: ~ + |user_default_options| - defaults options. + Fields: ~ |DEFAULT_NAMESPACE| - Default namespace used in `colorizer.buffer_utils.highlight_buffer` and `attach_to_buffer`. @@ -105,7 +108,7 @@ is_buffer_attached({buf}) *colorizer.is_buffer_attached* {buf} - number|nil: A value of 0 implies the current buffer. returns:~ - number|nil: if attached to the buffer, false otherwise. + number or nil: if attached to the buffer, false otherwise. See also:~ |highlight_buffer| @@ -149,25 +152,12 @@ setup({config}) *colorizer.setup* > require("colorizer").setup { 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. - virtualtext = "■", - }, + user_default_options, -- all the sub-options of filetypes apply to buftypes buftypes = {}, } < + For all user_default_options, see |user_default_options| Parameters: ~ @@ -196,6 +186,46 @@ clear_highlight_cache() *colorizer.clear_highlight_cache* +user_default_options *colorizer.user_default_options* + defaults options. + +> + 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 / "normal" / "lsp" / "both" + tailwind = false -- Enable tailwind colors + virtualtext = "■", + } +< + + + Fields: ~ + {RGB} - boolean + {RRGGBB} - boolean + {names} - boolean + {RRGGBBAA} - boolean + {AARRGGBB} - boolean + {rgb_fn} - boolean + {hsl_fn} - boolean + {css} - boolean + {css_fn} - boolean + {mode} - string + {tailwind} - boolean|string + {virtualtext} - string + + + DEFAULT_NAMESPACE *colorizer.DEFAULT_NAMESPACE* Default namespace used in `colorizer.buffer_utils.highlight_buffer` and `attach_to_buffer`. @@ -231,7 +261,7 @@ Fields: ~ *colorizer.buffer_utils.highlight_buffer* -highlight_buffer({buf}, {ns}, {lines}, {line_start}, {options}) +highlight_buffer({buf}, {ns}, {lines}, {line_start}, {options}, {options_local}) Highlight the buffer region. Highlight starting from `line_start` (0-indexed) for each line described by @@ -246,15 +276,25 @@ highlight_buffer({buf}, {ns}, {lines}, {line_start}, {options}) {lines} - table: the lines to highlight from the buffer. {line_start} - number: line_start should be 0-indexed {options} - table: Configuration options as described in `setup` + {options_local} - table: Buffer local variables + + returns:~ + nil or boolean or number,function or nil + -rehighlight_buffer({buf}, {options}) *colorizer.buffer_utils.rehighlight_buffer* + *colorizer.buffer_utils.rehighlight_buffer* +rehighlight_buffer({buf}, {options}, {options_local}) Rehighlight the buffer if colorizer is active Parameters: ~ {buf} - number: Buffer number {options} - table: Buffer options + {options_local} - table|nil: Buffer local variables + + returns:~ + nil or boolean or number,function or nil @@ -321,7 +361,7 @@ color_is_bright({r}, {g}, {b}) *colorizer.color_utils.color_is_bright* -color_name_parser({line}, {i}) *colorizer.color_utils.color_name_parser* +color_name_parser({line}, {i}, {opts}) *colorizer.color_utils.color_name_parser* Grab all the colour values from `vim.api.nvim_get_color_map` and create a lookup table. @@ -331,6 +371,7 @@ color_name_parser({line}, {i}) *colorizer.color_utils.color_name_parser* Parameters: ~ {line} - string: Line to parse {i} - number: Index of line from where to start parsing + {opts} - table: Currently contains whether tailwind is enabled or not @@ -342,8 +383,8 @@ rgb_function_parser({line}, {i}) *colorizer.color_utils.rgb_function_parser* {i} - number: Index of line from where to start parsing returns:~ - number|nil: Index of line where the rgb function ended - string|nil: rgb hex value + number or nil: Index of line where the rgb function ended + string or nil: rgb hex value @@ -360,8 +401,8 @@ rgba_function_parser({line}, {i}) *colorizer.color_utils.rgba_function_parser* {i} - number: Index of line from where to start parsing returns:~ - number|nil: Index of line where the rgba function ended - string|nil: rgb hex value + number or nil: Index of line where the rgba function ended + string or nil: rgb hex value @@ -373,8 +414,8 @@ hsl_function_parser({line}, {i}) *colorizer.color_utils.hsl_function_parser* {i} - number: Index of line from where to start parsing returns:~ - number|nil: Index of line where the hsl function ended - string|nil: rgb hex value + number or nil: Index of line where the hsl function ended + string or nil: rgb hex value @@ -386,8 +427,8 @@ hsla_function_parser({line}, {i}) *colorizer.color_utils.hsla_function_parser* {i} - number: Index of line from where to start parsing returns:~ - number|nil: Index of line where the hsla function ended - string|nil: rgb hex value + number or nil: Index of line where the hsla function ended + string or nil: rgb hex value @@ -402,8 +443,8 @@ argb_hex_parser({line}, {i}) *colorizer.color_utils.argb_hex_parser* {i} - number: index of line from where to start parsing returns:~ - number|nil: index of line where the hex value ended - string|nil: rgb hex value + number or nil: index of line where the hex value ended + string or nil: rgb hex value @@ -419,8 +460,8 @@ rgba_hex_parser({line}, {i}, {opts}) *colorizer.color_utils.rgba_hex_parser* {opts} - table: Containing minlen, maxlen, valid_lengths returns:~ - number|nil: index of line where the hex value ended - string|nil: rgb hex value + number or nil: index of line where the hex value ended + string or nil: rgb hex value @@ -449,7 +490,7 @@ make_matcher({options}) *colorizer.matcher_utils.make_matcher* {options} - table: options created in `colorizer.setup` returns:~ - function|boolean: function which will just parse the line for enabled + function or boolean: function which will just parse the line for enabled parsers diff --git a/doc/index.html b/doc/index.html index ae0a8d2..427033a 100644 --- a/doc/index.html +++ b/doc/index.html @@ -77,7 +77,7 @@
generated by LDoc 1.4.6 -Last updated 2022-09-03 17:24:13 +Last updated 2022-09-06 15:06:04
diff --git a/doc/ldoc_vim.ltp b/doc/ldoc_vim.ltp index baf388e..a664ffd 100644 --- a/doc/ldoc_vim.ltp +++ b/doc/ldoc_vim.ltp @@ -174,11 +174,12 @@ $(indent("", 2)){$(name)} - $(M(item.params.map[p],item)) $(indentstr)returns:~ # for i,group in ldoc.ipairs(groups) do local li,il = use_li(group) -# for r in group:iter() do local type, ctypes = item:return_type(r); local rt = ldoc.typename(type) +# for r in group:iter() do +# local type, ctypes = item:return_type(r); local rt = ldoc.typename(type) # if rt ~= '' then $(rt) # end -$(indent("", 2))$(r.text) +$(indent("", 2))$(r.text:gsub("|", " or ")) # if ctypes then # for c in ctypes:iter() do $(c.name) diff --git a/doc/modules/colorizer.buffer_utils.html b/doc/modules/colorizer.buffer_utils.html index f2f75fe..142164c 100644 --- a/doc/modules/colorizer.buffer_utils.html +++ b/doc/modules/colorizer.buffer_utils.html @@ -62,11 +62,11 @@

Functions

- + - +
highlight_buffer (buf, ns, lines, line_start, options)highlight_buffer (buf, ns, lines, line_start, options, options_local) Highlight the buffer region.
rehighlight_buffer (buf, options)rehighlight_buffer (buf, options, options_local) Rehighlight the buffer if colorizer is active
@@ -94,7 +94,7 @@
- highlight_buffer (buf, ns, lines, line_start, options) + highlight_buffer (buf, ns, lines, line_start, options, options_local)
Highlight the buffer region. @@ -119,8 +119,16 @@
  • options table: Configuration options as described in setup
  • +
  • options_local + table: Buffer local variables +
  • +

    Returns:

    +
      + + nil|boolean|number,function|nil +
    @@ -128,7 +136,7 @@
    - rehighlight_buffer (buf, options) + rehighlight_buffer (buf, options, options_local)
    Rehighlight the buffer if colorizer is active @@ -142,8 +150,16 @@
  • options table: Buffer options
  • +
  • options_local + table|nil: Buffer local variables +
  • +

    Returns:

    +
      + + nil|boolean|number,function|nil +
    @@ -215,7 +231,7 @@
    generated by LDoc 1.4.6 -Last updated 2022-09-03 17:24:13 +Last updated 2022-09-06 15:06:04
    diff --git a/doc/modules/colorizer.color_utils.html b/doc/modules/colorizer.color_utils.html index 613185c..8cd68e2 100644 --- a/doc/modules/colorizer.color_utils.html +++ b/doc/modules/colorizer.color_utils.html @@ -64,7 +64,7 @@ Determine whether to use black or white text. - color_name_parser (line, i) + color_name_parser (line, i, opts) Grab all the colour values from vim.api.nvim_get_color_map and create a lookup table. @@ -131,7 +131,7 @@
    - color_name_parser (line, i) + color_name_parser (line, i, opts)
    Grab all the colour values from vim.api.nvim_get_color_map and create a lookup table. @@ -146,6 +146,9 @@
  • i number: Index of line from where to start parsing
  • +
  • opts + table: Currently contains whether tailwind is enabled or not +
  • @@ -348,7 +351,7 @@
    generated by LDoc 1.4.6 -Last updated 2022-09-03 17:24:13 +Last updated 2022-09-06 15:06:04
    diff --git a/doc/modules/colorizer.html b/doc/modules/colorizer.html index 3db15a7..e02633c 100644 --- a/doc/modules/colorizer.html +++ b/doc/modules/colorizer.html @@ -33,6 +33,7 @@

    Contents

    @@ -155,6 +156,13 @@ USE WITH LUA Clear the highlight cache and reload all buffers. +

    Tables

    + + + + + +
    user_default_optionsdefaults options.

    Fields

    @@ -271,8 +279,7 @@ USE WITH LUA setup (config)
    - -

    Easy to use function if you want the full setup without fine grained control. + Easy to use function if you want the full setup without fine grained control. Setup an autocmd which enables colorizing for the filetypes and options specified.

    By default highlights all FileTypes.

    @@ -288,26 +295,13 @@ Setup an autocmd which enables colorizing for the filetypes and options specifie
         require("colorizer").setup {
           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.
    -        virtualtext = "■",
    -      },
    +      user_default_options,
           -- all the sub-options of filetypes apply to buftypes
           buftypes = {},
         }
     
    - +

    For all userdefaultoptions, see |userdefaultoptions|

    Parameters:

    @@ -373,6 +367,85 @@ Setup an autocmd which enables colorizing for the filetypes and options specifie +
    + +

    Tables

    + +
    +
    + + user_default_options +
    +
    + +

    defaults options.

    + +
    +  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 / "normal" / "lsp" / "both"
    +      tailwind = false -- Enable tailwind colors
    +      virtualtext = "■",
    +  }
    +
    + + + + +

    Fields:

    +
      +
    • RGB + boolean +
    • +
    • RRGGBB + boolean +
    • +
    • names + boolean +
    • +
    • RRGGBBAA + boolean +
    • +
    • AARRGGBB + boolean +
    • +
    • rgb_fn + boolean +
    • +
    • hsl_fn + boolean +
    • +
    • css + boolean +
    • +
    • css_fn + boolean +
    • +
    • mode + string +
    • +
    • tailwind + boolean|string +
    • +
    • virtualtext + string +
    • +
    + + + + +

    Fields

    @@ -404,7 +477,7 @@ Setup an autocmd which enables colorizing for the filetypes and options specifie
    generated by LDoc 1.4.6 -Last updated 2022-09-03 17:24:13 +Last updated 2022-09-06 15:06:04
    diff --git a/doc/modules/colorizer.matcher_utils.html b/doc/modules/colorizer.matcher_utils.html index e709932..e4cccee 100644 --- a/doc/modules/colorizer.matcher_utils.html +++ b/doc/modules/colorizer.matcher_utils.html @@ -106,7 +106,7 @@ Do not try make the function again if it is present in the cache
    generated by LDoc 1.4.6 -Last updated 2022-09-03 17:24:13 +Last updated 2022-09-06 15:06:04
    diff --git a/doc/modules/colorizer.trie.html b/doc/modules/colorizer.trie.html index 0261786..e2c7192 100644 --- a/doc/modules/colorizer.trie.html +++ b/doc/modules/colorizer.trie.html @@ -62,7 +62,7 @@
    generated by LDoc 1.4.6 -Last updated 2022-09-03 17:24:13 +Last updated 2022-09-06 15:06:04
    diff --git a/doc/modules/utils.html b/doc/modules/utils.html index 3e3ff4d..ffe7615 100644 --- a/doc/modules/utils.html +++ b/doc/modules/utils.html @@ -224,7 +224,7 @@
    generated by LDoc 1.4.6 -Last updated 2022-09-03 17:24:13 +Last updated 2022-09-06 15:06:04
    diff --git a/doc/tags b/doc/tags index bb5229d..1041494 100644 --- a/doc/tags +++ b/doc/tags @@ -35,3 +35,4 @@ colorizer.matcher_utils.make_matcher colorizer.txt /*colorizer.matcher_utils.mak colorizer.reload_all_buffers colorizer.txt /*colorizer.reload_all_buffers* colorizer.setup colorizer.txt /*colorizer.setup* colorizer.trie-introduction colorizer.txt /*colorizer.trie-introduction* +colorizer.user_default_options colorizer.txt /*colorizer.user_default_options* -- cgit v1.2.3-70-g09d2