Module colorizer.config

Provides configuration options and utilities for setting up colorizer.

Functions

get_settings (opts) Initializes colorizer with user-provided options.
new_buffer_options (bufnr, bo_type) Retrieve default options or buffer-specific options.
get_options (bo_type, buftype, filetype) Retrieve options based on buffer type and file type.
set_bo_value (bo_type, value, options) Set options for a specific buffer or file type.
parse_buffer_options (options) Parse buffer Configuration and convert aliases to normal values

Tables

user_default_options Default user options for colorizer.
setup_options Options for colorizer that were passed in to setup function
default_options Plugin default options cache from vim.deepcopy
opts Configuration options for the `setup` function.


Functions

get_settings (opts)
Initializes colorizer with user-provided options. Merges default settings with any user-specified options, setting up `filetypes`, `user_default_options`, and `user_commands`.

Parameters:

  • opts opts User-provided configuration options.

Returns:

    table Final settings after merging user and default options.
new_buffer_options (bufnr, bo_type)
Retrieve default options or buffer-specific options.

Parameters:

  • bufnr number: The buffer number.
  • bo_type 'buftype'|'filetype': The type of buffer option
get_options (bo_type, buftype, filetype)
Retrieve options based on buffer type and file type. Prefer filetype.

Parameters:

  • bo_type 'buftype'|'filetype': The type of buffer option
  • buftype string: Buffer type.
  • filetype string: File type.

Returns:

    table
set_bo_value (bo_type, value, options)
Set options for a specific buffer or file type.

Parameters:

  • bo_type 'buftype'|'filetype': The type of buffer option
  • value string: The specific value to set.
  • options table: Options to associate with the value.
parse_buffer_options (options)
Parse buffer Configuration and convert aliases to normal values

Parameters:

  • options table: options table

Returns:

    table

Tables

user_default_options
Default user options for colorizer. This table defines individual options and alias options, allowing configuration of colorizer's behavior for different color formats (e.g., `#RGB`, `#RRGGBB`, `#AARRGGBB`, etc.).

**Individual Options**: Options like `names`, `RGB`, `RRGGBB`, `RRGGBBAA`, `hsl_fn`, `rgb_fn`, `AARRGGBB`, `tailwind`, and `sass` can be enabled or disabled independently.

**Alias Options**: `css` and `css_fn` enable multiple options at once. - `css_fn = true` enables `hsl_fn` and `rgb_fn`. - `css = true` enables `names`, `RGB`, `RRGGBB`, `RRGGBBAA`, `hsl_fn`, and `rgb_fn`.

**Option Priority**: Individual options have higher priority than aliases. If both `css` and `css_fn` are true, `css_fn` has more priority over `css`.

Fields:

  • RGB boolean: Enables `#RGB` hex codes.
  • RRGGBB boolean: Enables `#RRGGBB` hex codes.
  • names boolean: Enables named colors (e.g., "Blue").
  • names_custom table|function|nil: Extra color name to RGB value mappings should return a table of color names to RGB value pairs
  • RRGGBBAA boolean: Enables `#RRGGBBAA` hex codes.
  • AARRGGBB boolean: Enables `0xAARRGGBB` hex codes.
  • rgb_fn boolean: Enables CSS `rgb()` and `rgba()` functions.
  • hsl_fn boolean: Enables CSS `hsl()` and `hsla()` functions.
  • css boolean: Enables all CSS features (`rgb_fn`, `hsl_fn`, `names`, `RGB`, `RRGGBB`).
  • css_fn boolean: Enables all CSS functions (`rgb_fn`, `hsl_fn`).
  • mode 'background'|'foreground'|'virtualtext': Display mode
  • tailwind boolean|string: Enables Tailwind CSS colors (e.g., `"normal"`, `"lsp"`, `"both"`).
  • sass table: Sass color configuration (`enable` flag and `parsers`).
  • virtualtext string: Character used for virtual text display.
  • virtualtext_inline boolean: Shows virtual text inline with color.
  • virtualtext_mode 'background'|'foreground': Mode for virtual text display.
  • always_update boolean: Always update color values, even if buffer is not focused.
setup_options
Options for colorizer that were passed in to setup function

Fields:

  • exclusions table
  • all table
  • default_options table
  • user_commands boolean
  • filetypes table
  • buftypes table
default_options
Plugin default options cache from vim.deepcopy
opts
Configuration options for the `setup` function.

Fields:

  • filetypes table A list of file types where colorizer should be enabled. Use `"*"` for all file types.
  • user_default_options table Default options for color handling. - `RGB` (boolean): Enables support for `#RGB` hex codes. - `RRGGBB` (boolean): Enables support for `#RRGGBB` hex codes. - `names` (boolean): Enables named color codes like `"Blue"`. - `names_custom` (table|function): Extra color name to RGB value mappings - `RRGGBBAA` (boolean): Enables support for `#RRGGBBAA` hex codes. - `AARRGGBB` (boolean): Enables support for `0xAARRGGBB` hex codes. - `rgb_fn` (boolean): Enables CSS `rgb()` and `rgba()` functions. - `hsl_fn` (boolean): Enables CSS `hsl()` and `hsla()` functions. - `css` (boolean): Enables all CSS-related features (e.g., `names`, `RGB`, `RRGGBB`, `hsl_fn`, `rgb_fn`). - `css_fn` (boolean): Enables all CSS function-related features (e.g., `rgb_fn`, `hsl_fn`). - `mode` (string): Determines the display mode for highlights. Options are `"background"`, `"foreground"`, and `"virtualtext"`. - `tailwind` (boolean|string): Enables Tailwind CSS colors. Accepts `true`, `"normal"`, `"lsp"`, or `"both"`. - `sass` (table): Configures Sass color support. - `enable` (boolean): Enables Sass color parsing. - `parsers` (table): A list of parsers to use, typically includes `"css"`. - `virtualtext` (string): Character used for virtual text display of colors (default is `"■"`). - `virtualtext_inline` (boolean): If true, shows the virtual text inline with the color. - `virtualtext_mode` ('background'|'foreground'): Determines the display mode for virtual text. - `always_update` (boolean): If true, updates color values even if the buffer is not focused.
  • buftypes table|nil Optional. A list of buffer types where colorizer should be enabled. Defaults to all buffer types if not provided.
  • user_commands boolean|table If true, enables all user commands for colorizer. If `false`, disables user commands. Alternatively, provide a table of specific commands to enable: - `"ColorizerAttachToBuffer"` - `"ColorizerDetachFromBuffer"` - `"ColorizerReloadAllBuffers"` - `"ColorizerToggle"`
generated by LDoc 1.5.0 Last updated - December