From 9c21bd06a228ff6a7c1087223d4eeb1fb0dec8ee Mon Sep 17 00:00:00 2001 From: jules Date: Sat, 30 Aug 2025 12:12:14 -0400 Subject: [PATCH 1/2] ui/nvim-highlight-colors: init --- docs/release-notes/rl-0.8.md | 7 ++ modules/plugins/ui/default.nix | 1 + .../ui/nvim-highlight-colors/config.nix | 25 +++++ .../ui/nvim-highlight-colors/default.nix | 6 ++ .../nvim-highlight-colors.nix | 92 +++++++++++++++++++ npins/sources.json | 13 +++ 6 files changed, 144 insertions(+) create mode 100644 modules/plugins/ui/nvim-highlight-colors/config.nix create mode 100644 modules/plugins/ui/nvim-highlight-colors/default.nix create mode 100644 modules/plugins/ui/nvim-highlight-colors/nvim-highlight-colors.nix diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index d2a1a098..74a94b9c 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -492,3 +492,10 @@ - Fix default [blink.cmp] sources "path" and "buffer" not working when `autocomplete.nvim-cmp.enable` was disabled and `autocomplete.nvim-cmp.sources` had not been modified. + +[Jules](https://github.com/jules-sommer): + +[nvim-highlight-colors]: https://github.com/brenoprata10/nvim-highlight-colors + +- Add [nvim-highlight-colors] plugin in `vim.ui.nvim-highlight-colors` with + `enable` and `setupOpts` diff --git a/modules/plugins/ui/default.nix b/modules/plugins/ui/default.nix index 50112650..d7d7592f 100644 --- a/modules/plugins/ui/default.nix +++ b/modules/plugins/ui/default.nix @@ -3,6 +3,7 @@ ./borders ./breadcrumbs ./colorful-menu-nvim + ./nvim-highlight-colors ./colorizer ./fastaction ./illuminate diff --git a/modules/plugins/ui/nvim-highlight-colors/config.nix b/modules/plugins/ui/nvim-highlight-colors/config.nix new file mode 100644 index 00000000..69867edd --- /dev/null +++ b/modules/plugins/ui/nvim-highlight-colors/config.nix @@ -0,0 +1,25 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; + + cfg = config.vim.ui.nvim-highlight-colors; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = [ + "nvim-highlight-colors" + ]; + + options.termguicolors = true; + + pluginRC.nvim-highlight-colors = entryAnywhere '' + require('nvim-highlight-colors').setup(${toLuaObject cfg.setupOpts}) + ''; + }; + }; +} diff --git a/modules/plugins/ui/nvim-highlight-colors/default.nix b/modules/plugins/ui/nvim-highlight-colors/default.nix new file mode 100644 index 00000000..85e03a89 --- /dev/null +++ b/modules/plugins/ui/nvim-highlight-colors/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./nvim-highlight-colors.nix + ./config.nix + ]; +} diff --git a/modules/plugins/ui/nvim-highlight-colors/nvim-highlight-colors.nix b/modules/plugins/ui/nvim-highlight-colors/nvim-highlight-colors.nix new file mode 100644 index 00000000..f0952d10 --- /dev/null +++ b/modules/plugins/ui/nvim-highlight-colors/nvim-highlight-colors.nix @@ -0,0 +1,92 @@ +{lib, ...}: let + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) attrsOf enum nullOr submodule bool str; + inherit (lib.modules) mkRenamedOptionModule; + inherit (lib.nvim.types) mkPluginSetupOption; + inherit (lib.nvim.config) mkBool; +in { + options.vim.ui.nvim-highlight-colors = { + enable = mkEnableOption "color highlighting [nvim-highlight-colors.lua]"; + + setupOpts = mkPluginSetupOption "nvim-highlight-colors" { + render = mkOption { + type = enum ["background" "foreground" "virtual"]; + default = "background"; + example = "virtual"; + description = '' + Style to render color highlighting with. + + ::: {.note} + Each render style works as follows: + - 'background' sets the background + highlight of the matched color string + to the RGB color it describes. + + - 'foreground' sets the foreground + highlight of the matched color string + to the RGB color it describes. + + - 'virtual' displays the matched color + with virtual text alongside the color + string in the buffer. Virtual text can + be configured to display the color in + various ways, i.e custom virtual symbol + (via `virtual_symbol`) positioning + relative to string, suffix/prefix, etc. + ::: + ''; + }; + + virtual_symbol = mkOption { + type = nullOr str; + default = "■"; + example = "⬤"; + description = '' + Symbol to display color with as virtual text. + + ::: {.note} + Only applies when `render` is set to 'virtual'. + ::: + ''; + }; + + virtual_symbol_prefix = mkOption { + type = nullOr str; + default = ""; + description = '' + String used as a prefix to the virtual_symbol + For example, to add padding between the color + string and the virtual symbol. + + ::: {.note} + Only applies when `render` is set to 'virtual'. + ::: + ''; + }; + + virtual_symbol_suffix = mkOption { + type = nullOr str; + default = " "; + description = '' + String used as a suffix to the virtual_symbol + For example, to add padding between the virtual + symbol and other text in the buffer. + + ::: {.note} + Only applies when `render` is set to 'virtual'. + ::: + ''; + }; + + enable_hex = mkBool true "Enable highlighting for hex color strings, i.e `#FFFFFF`."; + enable_short_hex = mkBool true "Enable highlighting for shorthand hex color format, i.e `#FFF`."; + enable_rgb = mkBool true "Enable highlighting for RGB color strings, i.e `rgb(0, 0, 0)` or `rgb(0 0 0)`."; + enable_hsl = mkBool true "Enable highlighting for HSL color strings, i.e `hsl(150deg 30% 40%)`."; + enable_ansi = mkBool true "Enable highlighting for HSL color strings, i.e `\033[0;34m`."; + enable_hsl_without_function = mkBool true "Enable highlighting for bare HSL color strings, i.e `--foreground: 0 69% 69%;`."; + enable_var_usage = mkBool true "Enable highlighting for CSS variables which reference colors, i.e `var(--testing-color)`."; + enable_named_colors = mkBool true "Enable highlighting for named colors, i.e `green`."; + enable_tailwind = mkBool false "Enable highlighting for tailwind color classes, i.e `bg-blue-500`."; + }; + }; +} diff --git a/npins/sources.json b/npins/sources.json index 010dd3ce..d78175c3 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -1838,6 +1838,19 @@ "url": "https://github.com/amrbashir/nvim-docs-view/archive/f674ba57349849bce894efdd54096483c88e810b.tar.gz", "hash": "0ifbfhifly5sdsbxv1p71wvl644jz505ln9j1yr6qwvyk6a2krm1" }, + "nvim-highlight-colors": { + "type": "Git", + "repository": { + "type": "GitHub", + "owner": "brenoprata10", + "repo": "nvim-highlight-colors" + }, + "branch": "main", + "submodules": false, + "revision": "1ce0a09bfc28c7274e649d20927cea51e440b65c", + "url": "https://github.com/brenoprata10/nvim-highlight-colors/archive/1ce0a09bfc28c7274e649d20927cea51e440b65c.tar.gz", + "hash": "1wsscm2mycd7zalxv8paa3fk0qy46bbhq4yfr73sl71wvkdh6yjn" + }, "nvim-lightbulb": { "type": "Git", "repository": { From d76b4284b044882b5bdb31308937c172aebf7697 Mon Sep 17 00:00:00 2001 From: jules Date: Sun, 31 Aug 2025 13:49:17 -0400 Subject: [PATCH 2/2] ui/nvim-highlight-colors: remove untyped vendored options --- .../ui/nvim-highlight-colors/config.nix | 3 + .../nvim-highlight-colors.nix | 67 +++++++------------ 2 files changed, 26 insertions(+), 44 deletions(-) diff --git a/modules/plugins/ui/nvim-highlight-colors/config.nix b/modules/plugins/ui/nvim-highlight-colors/config.nix index 69867edd..117c6922 100644 --- a/modules/plugins/ui/nvim-highlight-colors/config.nix +++ b/modules/plugins/ui/nvim-highlight-colors/config.nix @@ -15,6 +15,9 @@ in { "nvim-highlight-colors" ]; + # enable display of 24-bit RGB colors in neovim + # via the terminal. This is required for nvim-highlight-colors + # to display arbitrary RGB highlights. options.termguicolors = true; pluginRC.nvim-highlight-colors = entryAnywhere '' diff --git a/modules/plugins/ui/nvim-highlight-colors/nvim-highlight-colors.nix b/modules/plugins/ui/nvim-highlight-colors/nvim-highlight-colors.nix index f0952d10..c5ccc854 100644 --- a/modules/plugins/ui/nvim-highlight-colors/nvim-highlight-colors.nix +++ b/modules/plugins/ui/nvim-highlight-colors/nvim-highlight-colors.nix @@ -37,56 +37,35 @@ in { ''; }; - virtual_symbol = mkOption { - type = nullOr str; - default = "■"; - example = "⬤"; + virtual_symbol_position = mkOption { + type = enum ["inline" "eol" "eow"]; + default = "inline"; + example = "eol"; description = '' - Symbol to display color with as virtual text. + Where to render the virtual symbol in + relation to the color string. ::: {.note} - Only applies when `render` is set to 'virtual'. + Each render style works as follows: + - 'inline' render virtual text inline, + similar to the style of VSCode color + hinting. + + - 'eol' render virtual text at the end + of the line which the color string + occurs (last column). Recommended to + set `virtual_symbol_suffix` to an + empty string when used. + + - 'eow' render virtual text at the end + of the word where the color string + occurs. Recommended to set + `virtual_symbol_prefix` to a single + space for padding and the suffix to + an empty string for no padding. ::: ''; }; - - virtual_symbol_prefix = mkOption { - type = nullOr str; - default = ""; - description = '' - String used as a prefix to the virtual_symbol - For example, to add padding between the color - string and the virtual symbol. - - ::: {.note} - Only applies when `render` is set to 'virtual'. - ::: - ''; - }; - - virtual_symbol_suffix = mkOption { - type = nullOr str; - default = " "; - description = '' - String used as a suffix to the virtual_symbol - For example, to add padding between the virtual - symbol and other text in the buffer. - - ::: {.note} - Only applies when `render` is set to 'virtual'. - ::: - ''; - }; - - enable_hex = mkBool true "Enable highlighting for hex color strings, i.e `#FFFFFF`."; - enable_short_hex = mkBool true "Enable highlighting for shorthand hex color format, i.e `#FFF`."; - enable_rgb = mkBool true "Enable highlighting for RGB color strings, i.e `rgb(0, 0, 0)` or `rgb(0 0 0)`."; - enable_hsl = mkBool true "Enable highlighting for HSL color strings, i.e `hsl(150deg 30% 40%)`."; - enable_ansi = mkBool true "Enable highlighting for HSL color strings, i.e `\033[0;34m`."; - enable_hsl_without_function = mkBool true "Enable highlighting for bare HSL color strings, i.e `--foreground: 0 69% 69%;`."; - enable_var_usage = mkBool true "Enable highlighting for CSS variables which reference colors, i.e `var(--testing-color)`."; - enable_named_colors = mkBool true "Enable highlighting for named colors, i.e `green`."; - enable_tailwind = mkBool false "Enable highlighting for tailwind color classes, i.e `bg-blue-500`."; }; }; }