From f986d9a0ea1feff1388b5c7d297ec3faa19036a7 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Fri, 9 Sep 2022 23:55:43 +0530 Subject: [FEATURE] Add support for sass variables Import support import using use and import keyword multiple imports in single line multiple imports in multiple lines ( using commas ) recursive imports watch imports for changes and automatically rehighlight buffer buffer variables recursive variables support multiple variables in single line parse imported files only when they are changed Loosely based on https://github.com/norcalli/nvim-colorizer.lua/pull/22/files --- doc/colorizer.txt | 64 ++++++++++++++++++- doc/modules/colorizer.buffer_utils.html | 4 +- doc/modules/colorizer.color_utils.html | 110 ++++++++++++++++++++++++++++++++ doc/modules/colorizer.html | 7 +- doc/modules/colorizer.utils.html | 87 ------------------------- doc/modules/trie.html | 80 ----------------------- doc/modules/utils.html | 64 +++++++++++++++++++ doc/tags | 4 ++ 8 files changed, 247 insertions(+), 173 deletions(-) delete mode 100644 doc/modules/colorizer.utils.html delete mode 100644 doc/modules/trie.html (limited to 'doc') diff --git a/doc/colorizer.txt b/doc/colorizer.txt index 3661d8f..87a3a90 100644 --- a/doc/colorizer.txt +++ b/doc/colorizer.txt @@ -208,7 +208,9 @@ user_default_options *colorizer.user_default_options* mode = "background", -- Set the display mode. -- Available methods are false / true / "normal" / "lsp" / "both" -- True is same as normal - tailwind = false -- Enable tailwind colors + tailwind = false, -- Enable tailwind colors + -- parsers can contain values used in |user_default_options| + sass = { enable = false, parsers = { css }, }, -- Enable sass colors virtualtext = "■", } < @@ -226,6 +228,7 @@ user_default_options *colorizer.user_default_options* {css_fn} - boolean {mode} - string {tailwind} - boolean|string + {sass} - table {virtualtext} - string @@ -292,7 +295,7 @@ highlight_buffer({buf}, {ns}, {lines}, {line_start}, {line_end}, {options}, {options_local} - table: Buffer local variables returns:~ - nil or boolean or number,function or nil + nil or boolean or number,table @@ -309,7 +312,7 @@ rehighlight_buffer({buf}, {options}, {options_local}, {use_local_lines}) options_local returns:~ - nil or boolean or number,function or nil + nil or boolean or number,table @@ -348,6 +351,14 @@ Functions: ~ |color_name_parser| - Grab all the colour values from `vim.api.nvim_get_color_map` and create a lookup table. + |sass_cleanup| - Cleanup sass variables + + |sass_update_variables| - Parse the given lines for sass variabled and add + to SASS[buf].DEFINITIONS_ALL. + + |sass_name_parser| - Parse the given line for sass color names + check for value in SASS[buf].DEFINITIONS_ALL + |rgb_function_parser| - Parse for rgb() css function and return rgb hex. |rgba_function_parser| - Parse for rgba() css function and return rgb hex. @@ -390,6 +401,53 @@ color_name_parser({line}, {i}, {opts}) *colorizer.color_utils.color_name_parser* +sass_cleanup({buf}) *colorizer.color_utils.sass_cleanup* + Cleanup sass variables + + Parameters: ~ + {buf} - number + + + + + *colorizer.color_utils.sass_update_variables* +sass_update_variables({buf}, {line_start}, {line_end}, {lines}, {color_parser}, +{options}, {options_local}) + Parse the given lines for sass variabled and add to + SASS[buf].DEFINITIONS_ALL. + + which is then used in |sass_name_parser| + If lines are not given, then fetch the lines with line_start and line_end + + + Parameters: ~ + {buf} - number + {line_start} - number + {line_end} - number + {lines} - table|nil + {color_parser} - function|boolean + {options} - table: Buffer options + {options_local} - table|nil: Buffer local variables + + returns:~ + boolean + + + +sass_name_parser({line}, {i}, {buf}) *colorizer.color_utils.sass_name_parser* + Parse the given line for sass color names + check for value in SASS[buf].DEFINITIONS_ALL + + Parameters: ~ + {line} - string: Line to parse + {i} - number: Index of line from where to start parsing + {buf} - number + + returns:~ + number or nil, string or nil + + + rgb_function_parser({line}, {i}) *colorizer.color_utils.rgb_function_parser* Parse for rgb() css function and return rgb hex. diff --git a/doc/modules/colorizer.buffer_utils.html b/doc/modules/colorizer.buffer_utils.html index 7260c5c..8d7beaa 100644 --- a/doc/modules/colorizer.buffer_utils.html +++ b/doc/modules/colorizer.buffer_utils.html @@ -148,7 +148,7 @@

Returns:

    - nil|boolean|number,function|nil + nil|boolean|number,table
@@ -182,7 +182,7 @@

Returns:

    - nil|boolean|number,function|nil + nil|boolean|number,table
diff --git a/doc/modules/colorizer.color_utils.html b/doc/modules/colorizer.color_utils.html index a02853b..6e26961 100644 --- a/doc/modules/colorizer.color_utils.html +++ b/doc/modules/colorizer.color_utils.html @@ -66,6 +66,19 @@ color_name_parser (line, i, opts) Grab all the colour values from vim.api.nvim_get_color_map and create a lookup table. + + + sass_cleanup (buf) + Cleanup sass variables + + + sass_update_variables (buf, line_start, line_end, lines, color_parser, options, options_local) + Parse the given lines for sass variabled and add to SASS[buf].DEFINITIONS_ALL. + + + sass_name_parser (line, i, buf) + Parse the given line for sass color names + check for value in SASS[buf].DEFINITIONS_ALL rgb_function_parser (line, i) @@ -155,6 +168,103 @@ + +
+ + sass_cleanup (buf) +
+
+ Cleanup sass variables + + +

Parameters:

+ + + + + + +
+
+ + sass_update_variables (buf, line_start, line_end, lines, color_parser, options, options_local) +
+
+ Parse the given lines for sass variabled and add to SASS[buf].DEFINITIONSALL. + which is then used in |sassnameparser| + If lines are not given, then fetch the lines with linestart and line_end + + +

Parameters:

+ + +

Returns:

+
    + + boolean +
+ + + + +
+
+ + sass_name_parser (line, i, buf) +
+
+ Parse the given line for sass color names + check for value in SASS[buf].DEFINITIONS_ALL + + +

Parameters:

+ + +

Returns:

+
    + + number|nil, string|nil +
+ + + +
diff --git a/doc/modules/colorizer.html b/doc/modules/colorizer.html index 311bd60..edc06db 100644 --- a/doc/modules/colorizer.html +++ b/doc/modules/colorizer.html @@ -400,7 +400,9 @@ Setup an autocmd which enables colorizing for the filetypes and options specifie mode = "background", -- Set the display mode. -- Available methods are false / true / "normal" / "lsp" / "both" -- True is same as normal - tailwind = false -- Enable tailwind colors + tailwind = false, -- Enable tailwind colors + -- parsers can contain values used in |user_default_options| + sass = { enable = false, parsers = { css }, }, -- Enable sass colors virtualtext = "■", } @@ -443,6 +445,9 @@ Setup an autocmd which enables colorizing for the filetypes and options specifie
  • tailwind boolean|string
  • +
  • sass + table +
  • virtualtext string
  • diff --git a/doc/modules/colorizer.utils.html b/doc/modules/colorizer.utils.html deleted file mode 100644 index 9bca259..0000000 --- a/doc/modules/colorizer.utils.html +++ /dev/null @@ -1,87 +0,0 @@ -============================================================================== -UTILS *colorizer.utils* - -Helper utils - - -============================================================================== -LUA API *colorizer.utils* - -Available Functions: - - |colorizer.utils.byte_is_alphanumeric| - Obvious - - |colorizer.utils.byte_is_hex| - Obvious - - |colorizer.utils.merge| - Merge two tables - TODO Remove this and use vim.tbl_deep_extend - - |colorizer.utils.parse_hex| - Obvious - - |colorizer.utils.percent_or_hex| - Obvious - - - -byte_is_alphanumeric({byte}) |colorizer.utils.byte_is_alphanumeric| - Obvious - - - Parameters: - {byte} - number - - Returns: - boolean - - - -byte_is_hex({byte}) |colorizer.utils.byte_is_hex| - Obvious - - - Parameters: - {byte} - number - - Returns: - boolean - - - -merge({...}) |colorizer.utils.merge| - Merge two tables - TODO Remove this and use vim.tbl_deep_extend - - - Parameters: - {...} - - - Returns: - table - - - -parse_hex({byte}) |colorizer.utils.parse_hex| - Obvious - - - Parameters: - {byte} - number - - Returns: - number - - - -percent_or_hex({v}) |colorizer.utils.percent_or_hex| - Obvious - - - Parameters: - {v} - string - - Returns: - number|nil - - - - - vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/doc/modules/trie.html b/doc/modules/trie.html deleted file mode 100644 index e353630..0000000 --- a/doc/modules/trie.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - colorizer Docs - - - - -
    - -
    - -
    -
    -
    - - -
    - - - - - - -
    - -

    Module trie

    -

    Trie implementation in luajit.

    -

    Copyright © 2019 Ashkan Kiani - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version.

    - -

    This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see http://www.gnu.org/licenses/.

    - - - -
    -
    - - - - -
    -
    -
    -generated by LDoc 1.4.6 -Last updated 2022-09-02 21:37:16 -
    -
    - - diff --git a/doc/modules/utils.html b/doc/modules/utils.html index 8ff8fed..3e6fb0a 100644 --- a/doc/modules/utils.html +++ b/doc/modules/utils.html @@ -79,6 +79,14 @@ percent_or_hex (v) Obvious. + + get_last_modified (path) + Get last modified time of a file + + + watch_file (path, callback, ...) + Watch a file for changes and execute callback +
    @@ -216,6 +224,62 @@ + +
    + + get_last_modified (path) +
    +
    + Get last modified time of a file + + +

    Parameters:

    + + +

    Returns:

    +
      + + number|nil: modified time +
    + + + + +
    +
    + + watch_file (path, callback, ...) +
    +
    + Watch a file for changes and execute callback + + +

    Parameters:

    + + +

    Returns:

    +
      + + function|nil +
    + + + +
    diff --git a/doc/tags b/doc/tags index 1041494..2e81666 100644 --- a/doc/tags +++ b/doc/tags @@ -12,6 +12,7 @@ colorizer.buffer_utils-introduction colorizer.txt /*colorizer.buffer_utils-intro colorizer.buffer_utils-lua-api colorizer.txt /*colorizer.buffer_utils-lua-api* colorizer.buffer_utils.DEFAULT_NAMESPACE colorizer.txt /*colorizer.buffer_utils.DEFAULT_NAMESPACE* colorizer.buffer_utils.HIGHLIGHT_MODE_NAMES colorizer.txt /*colorizer.buffer_utils.HIGHLIGHT_MODE_NAMES* +colorizer.buffer_utils.clear_hl_cache colorizer.txt /*colorizer.buffer_utils.clear_hl_cache* colorizer.buffer_utils.highlight_buffer colorizer.txt /*colorizer.buffer_utils.highlight_buffer* colorizer.buffer_utils.rehighlight_buffer colorizer.txt /*colorizer.buffer_utils.rehighlight_buffer* colorizer.clear_highlight_cache colorizer.txt /*colorizer.clear_highlight_cache* @@ -25,6 +26,9 @@ colorizer.color_utils.hsla_function_parser colorizer.txt /*colorizer.color_utils colorizer.color_utils.rgb_function_parser colorizer.txt /*colorizer.color_utils.rgb_function_parser* colorizer.color_utils.rgba_function_parser colorizer.txt /*colorizer.color_utils.rgba_function_parser* colorizer.color_utils.rgba_hex_parser colorizer.txt /*colorizer.color_utils.rgba_hex_parser* +colorizer.color_utils.sass_cleanup colorizer.txt /*colorizer.color_utils.sass_cleanup* +colorizer.color_utils.sass_name_parser colorizer.txt /*colorizer.color_utils.sass_name_parser* +colorizer.color_utils.sass_update_variables colorizer.txt /*colorizer.color_utils.sass_update_variables* colorizer.detach_from_buffer colorizer.txt /*colorizer.detach_from_buffer* colorizer.get_buffer_options colorizer.txt /*colorizer.get_buffer_options* colorizer.highlight_buffer colorizer.txt /*colorizer.highlight_buffer* -- cgit v1.2.3-70-g09d2