From 3c73befdc5ef1ad1a635360ee9db97d800f8d966 Mon Sep 17 00:00:00 2001 From: Jens Feodor Nielsen Date: Tue, 16 Dec 2025 16:31:38 +0100 Subject: [PATCH 1/2] utility/ccc: add inputs and outputs options Added `ccc.nvim` options `vim.utility.ccc.inputs` and `vim.utility.ccc.outputs` to make input color systems and output color formats configurable. --- docs/manual/release-notes/rl-0.8.md | 10 ++++- modules/plugins/utility/ccc/ccc.nix | 59 +++++++++++++++++++++++++- modules/plugins/utility/ccc/config.nix | 9 ++-- 3 files changed, 70 insertions(+), 8 deletions(-) diff --git a/docs/manual/release-notes/rl-0.8.md b/docs/manual/release-notes/rl-0.8.md index fadb2e69..6fec61ca 100644 --- a/docs/manual/release-notes/rl-0.8.md +++ b/docs/manual/release-notes/rl-0.8.md @@ -622,8 +622,16 @@ - Added gitFiles mapping option to telescope -[Ring-A-Ding-Ding-Baby](https://github.com/Ring-A-Ding-Ding-Baby) +[Ring-A-Ding-Ding-Baby](https://github.com/Ring-A-Ding-Ding-Baby): - Aligned `codelldb` adapter setup with [rustaceanvim]’s built-in logic. - Added `languages.rust.dap.backend` option to choose between `codelldb` and `lldb-dap` adapters. + +[jfeo](https://github.com/jfeo): + +[ccc.nvim]: https://github.com/uga-rosa/ccc.nvim + +- Added [ccc.nvim] options {option}`vim.utility.ccc.inputs` and + {option}`vim.utility.ccc.outputs` to make input color systems and output color + formats configurable. diff --git a/modules/plugins/utility/ccc/ccc.nix b/modules/plugins/utility/ccc/ccc.nix index f900b531..e51d86da 100644 --- a/modules/plugins/utility/ccc/ccc.nix +++ b/modules/plugins/utility/ccc/ccc.nix @@ -1,10 +1,67 @@ {lib, ...}: let - inherit (lib.options) mkEnableOption; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) listOf enum; inherit (lib.nvim.binds) mkMappingOption; in { options.vim.utility.ccc = { enable = mkEnableOption "ccc color picker for neovim"; + inputs = mkOption { + type = listOf (enum [ + "rgb" + "hsl" + "hwb" + "lab" + "lch" + "oklab" + "oklch" + "cmyk" + "hsluv" + "okhsl" + "hsv" + "okhsv" + "xyz" + ]); + default = [ + "hsl" + ]; + description = '' + List of color systems to be activated. + + The toggle input mode action toggles in this order. The first one is + the default used at the first startup. Once activated, it will keep the + previous input mode. + ''; + }; + + outputs = mkOption { + type = listOf (enum [ + "hex" + "hex_short" + "css_hsl" + "css_rgb" + "css_rgba" + "css_hwb" + "css_lab" + "css_lch" + "css_oklab" + "css_oklch" + "float" + ]); + default = [ + "css_hsl" + "css_rgb" + "hex" + ]; + description = '' + List of output formats to be activated. + + The toggle output mode action toggles in this order. The first one is + the default used at the first startup. Once activated, it will keep the + previous output mode. + ''; + }; + mappings = { quit = mkMappingOption "Cancel and close the UI without replace or insert" ""; increase10 = mkMappingOption "Increase the value times delta of the slider" ""; diff --git a/modules/plugins/utility/ccc/config.nix b/modules/plugins/utility/ccc/config.nix index 33948562..e978ed14 100644 --- a/modules/plugins/utility/ccc/config.nix +++ b/modules/plugins/utility/ccc/config.nix @@ -3,6 +3,7 @@ lib, ... }: let + inherit (lib.strings) concatStringsSep; inherit (lib.modules) mkIf; inherit (lib.nvim.dag) entryAnywhere; @@ -30,12 +31,8 @@ in { }, alpha_show = "hide", -- needed when highlighter.lsp is set to true recognize = { output = true }, -- automatically recognize color format under cursor - inputs = { ccc.input.hsl }, - outputs = { - ccc.output.css_hsl, - ccc.output.css_rgb, - ccc.output.hex, - }, + inputs = {${concatStringsSep "," (map (input: "ccc.input.${input}") cfg.inputs)}}, + outputs = {${concatStringsSep "," (map (output: "ccc.output.${output}") cfg.outputs)}}, convert = { { ccc.picker.hex, ccc.output.css_hsl }, { ccc.picker.css_rgb, ccc.output.css_hsl }, From 3e5c6eb73f0849fb1e2a0c7076f0cb1a6cd65b55 Mon Sep 17 00:00:00 2001 From: Jens Feodor Nielsen Date: Wed, 17 Dec 2025 16:44:44 +0100 Subject: [PATCH 2/2] utility/ccc: add setupOpts option Added `ccc.nvim` option `vim.utility.ccc.setupOpts` with the existing hard-coded options as default values. --- docs/manual/release-notes/rl-0.8.md | 5 +- modules/plugins/utility/ccc/ccc.nix | 189 ++++++++++++++++++------- modules/plugins/utility/ccc/config.nix | 42 ++---- 3 files changed, 150 insertions(+), 86 deletions(-) diff --git a/docs/manual/release-notes/rl-0.8.md b/docs/manual/release-notes/rl-0.8.md index 6fec61ca..bf1208b1 100644 --- a/docs/manual/release-notes/rl-0.8.md +++ b/docs/manual/release-notes/rl-0.8.md @@ -632,6 +632,5 @@ [ccc.nvim]: https://github.com/uga-rosa/ccc.nvim -- Added [ccc.nvim] options {option}`vim.utility.ccc.inputs` and - {option}`vim.utility.ccc.outputs` to make input color systems and output color - formats configurable. +- Added [ccc.nvim] option {option}`vim.utility.ccc.setupOpts` with the existing + hard-coded options as default values. diff --git a/modules/plugins/utility/ccc/ccc.nix b/modules/plugins/utility/ccc/ccc.nix index e51d86da..a8f19587 100644 --- a/modules/plugins/utility/ccc/ccc.nix +++ b/modules/plugins/utility/ccc/ccc.nix @@ -2,64 +2,151 @@ inherit (lib.options) mkOption mkEnableOption; inherit (lib.types) listOf enum; inherit (lib.nvim.binds) mkMappingOption; + inherit (lib.nvim.types) mkPluginSetupOption luaInline; + inherit (lib.generators) mkLuaInline; in { options.vim.utility.ccc = { enable = mkEnableOption "ccc color picker for neovim"; - inputs = mkOption { - type = listOf (enum [ - "rgb" - "hsl" - "hwb" - "lab" - "lch" - "oklab" - "oklch" - "cmyk" - "hsluv" - "okhsl" - "hsv" - "okhsv" - "xyz" - ]); - default = [ - "hsl" - ]; - description = '' - List of color systems to be activated. + setupOpts = mkPluginSetupOption "ccc.nvim" { + highlighter = mkOption { + type = luaInline; + default = mkLuaInline '' + { + auto_enable = true, + max_byte = 2 * 1024 * 1024, -- 2mb + lsp = true, + filetypes = colorPickerFts, + } + ''; + description = "Settings for the highlighter"; + }; - The toggle input mode action toggles in this order. The first one is - the default used at the first startup. Once activated, it will keep the - previous input mode. - ''; - }; + pickers = mkOption { + type = luaInline; + default = mkLuaInline '' + { + ccc.picker.hex, + ccc.picker.css_rgb, + ccc.picker.css_hsl, + ccc.picker.ansi_escape { + meaning1 = "bright", -- whether the 1 means bright or yellow + }, + } + ''; + description = '' + List of formats that can be detected by |:CccPick| to be activated. + ''; + }; - outputs = mkOption { - type = listOf (enum [ - "hex" - "hex_short" - "css_hsl" - "css_rgb" - "css_rgba" - "css_hwb" - "css_lab" - "css_lch" - "css_oklab" - "css_oklch" - "float" - ]); - default = [ - "css_hsl" - "css_rgb" - "hex" - ]; - description = '' - List of output formats to be activated. + alpha_show = mkOption { + type = enum [ + "show" + "hide" + "auto" + ]; + default = "hide"; + description = '' + This option determines whether the alpha slider is displayed when the + UI is opened. "show" and "hide" mean as they are. "auto" makes the + slider appear only when the alpha value can be picked up. + ''; + }; - The toggle output mode action toggles in this order. The first one is - the default used at the first startup. Once activated, it will keep the - previous output mode. - ''; + recognize = mkOption { + type = luaInline; + default = mkLuaInline '' + { output = true } + ''; + description = "Settings for recognizing the color format."; + }; + + inputs = mkOption { + type = listOf (enum [ + "rgb" + "hsl" + "hwb" + "lab" + "lch" + "oklab" + "oklch" + "cmyk" + "hsluv" + "okhsl" + "hsv" + "okhsv" + "xyz" + ]); + default = [ + "hsl" + ]; + description = '' + List of color systems to be activated. + + The toggle input mode action toggles in this order. The first one is + the default used at the first startup. Once activated, it will keep the + previous input mode. + ''; + }; + + outputs = mkOption { + type = listOf (enum [ + "hex" + "hex_short" + "css_hsl" + "css_rgb" + "css_rgba" + "css_hwb" + "css_lab" + "css_lch" + "css_oklab" + "css_oklch" + "float" + ]); + default = [ + "css_hsl" + "css_rgb" + "hex" + ]; + description = '' + List of output formats to be activated. + + The toggle output mode action toggles in this order. The first one is + the default used at the first startup. Once activated, it will keep the + previous output mode. + ''; + }; + + convert = mkOption { + type = luaInline; + default = mkLuaInline '' + { + { ccc.picker.hex, ccc.output.css_hsl }, + { ccc.picker.css_rgb, ccc.output.css_hsl }, + { ccc.picker.css_hsl, ccc.output.hex }, + } + ''; + description = '' + Specify the correspondence between picker and output. + ''; + }; + + mappings = mkOption { + type = luaInline; + default = mkLuaInline '' + { + ["q"] = ccc.mapping.quit, + ["L"] = ccc.mapping.increase10, + ["H"] = ccc.mapping.decrease10, + } + ''; + description = '' + The mappings are set in the UI of ccc. The table where lhs is key and + rhs is value. To disable all default mappings, use + disable_default_mappings. To disable only some of the default + mappings, set ccc.mapping.none. + ''; + }; }; mappings = { diff --git a/modules/plugins/utility/ccc/config.nix b/modules/plugins/utility/ccc/config.nix index e978ed14..f8472649 100644 --- a/modules/plugins/utility/ccc/config.nix +++ b/modules/plugins/utility/ccc/config.nix @@ -3,47 +3,25 @@ lib, ... }: let - inherit (lib.strings) concatStringsSep; inherit (lib.modules) mkIf; inherit (lib.nvim.dag) entryAnywhere; - + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.generators) mkLuaInline; cfg = config.vim.utility.ccc; + mkLuaIdentifier = prefix: identifier: mkLuaInline "${prefix}${identifier}"; + mapSetupOptions = setupOpts: + setupOpts + // { + inputs = map (mkLuaIdentifier "ccc.input.") setupOpts.inputs; + outputs = map (mkLuaIdentifier "ccc.output.") setupOpts.outputs; + }; in { config = mkIf cfg.enable { vim.startPlugins = ["ccc-nvim"]; vim.pluginRC.ccc = entryAnywhere '' local ccc = require("ccc") - ccc.setup { - highlighter = { - auto_enable = true, - max_byte = 2 * 1024 * 1024, -- 2mb - lsp = true, - filetypes = colorPickerFts, - }, - pickers = { - ccc.picker.hex, - ccc.picker.css_rgb, - ccc.picker.css_hsl, - ccc.picker.ansi_escape { - meaning1 = "bright", -- whether the 1 means bright or yellow - }, - }, - alpha_show = "hide", -- needed when highlighter.lsp is set to true - recognize = { output = true }, -- automatically recognize color format under cursor - inputs = {${concatStringsSep "," (map (input: "ccc.input.${input}") cfg.inputs)}}, - outputs = {${concatStringsSep "," (map (output: "ccc.output.${output}") cfg.outputs)}}, - convert = { - { ccc.picker.hex, ccc.output.css_hsl }, - { ccc.picker.css_rgb, ccc.output.css_hsl }, - { ccc.picker.css_hsl, ccc.output.hex }, - }, - mappings = { - ["q"] = ccc.mapping.quit, - ["L"] = ccc.mapping.increase10, - ["H"] = ccc.mapping.decrease10, - }, - } + ccc.setup(${toLuaObject (mapSetupOptions cfg.setupOpts)}) ''; }; }