Module colorizer.utils

Utilities Provides utility functions for color handling and file operations.

This module contains helper functions for checking byte categories, merging tables, parsing colors, managing file watchers, and handling buffer lines.

Functions

bufme (bufnr) Validates and returns a buffer number.
byte_is_alphanumeric (byte) Checks if a byte represents an alphanumeric character.
byte_is_hex (byte) Checks if a byte represents a hexadecimal character.
byte_is_valid_color_char (byte) Checks if a byte is valid as a color character (alphanumeric, dynamically added chars, or hardcoded characters).
count (str, pattern) Count the number of character in a string
get_last_modified (path) Get last modified time of a file
get_non_alphanum_keys (tbl) Extract non-alphanumeric characters to add as a valid index in the Trie
hash_table (tbl) Returns sha256 hash of lua table
parse_hex (byte) Parses a hexadecimal byte.
reset_byte_category (chars) Adds additional characters to the list of valid color characters.
rgb_to_hex (r, g, b) Returns HEX format from RGB values
validate_css_seps (c_seps, s_seps, has_alpha, min_commas, min_spaces) Validate CSS separator syntax for color functions (rgb, hsl).
visible_line_range (bufnr) Returns range of visible lines
watch_file (path, callback, ...) Watch a file for changes and execute callback


Functions

bufme (bufnr)
Validates and returns a buffer number. If the provided buffer number is invalid, defaults to the current buffer.
byte_is_alphanumeric (byte)
Checks if a byte represents an alphanumeric character.
byte_is_hex (byte)
Checks if a byte represents a hexadecimal character.
byte_is_valid_color_char (byte)
Checks if a byte is valid as a color character (alphanumeric, dynamically added chars, or hardcoded characters). Additional chars added via addadditionalcolorchars set bytecategory[byte] = 1 (bit 0), which is caught by the alphanumeric check (bits 0-1). So a single non-zero check suffices.
count (str, pattern)
Count the number of character in a string
get_last_modified (path)
Get last modified time of a file
get_non_alphanum_keys (tbl)
Extract non-alphanumeric characters to add as a valid index in the Trie
hash_table (tbl)
Returns sha256 hash of lua table
parse_hex (byte)
Parses a hexadecimal byte.
reset_byte_category (chars)
Adds additional characters to the list of valid color characters. Reset byte_category to its initial state, clearing any dynamically added chars.
rgb_to_hex (r, g, b)
Returns HEX format from RGB values
validate_css_seps (c_seps, s_seps, has_alpha, min_commas, min_spaces)
Validate CSS separator syntax for color functions (rgb, hsl). Checks that comma or space separators follow the CSS specification. Comma syntax requires exactly min_commas commas. Space syntax requires at least min_spaces spaces, and alpha must use "/" separator.
visible_line_range (bufnr)
Returns range of visible lines
watch_file (path, callback, ...)
Watch a file for changes and execute callback
generated by LDoc 1.5.0 Last updated 2026-03-07 17:46:06