From d88a30fba6479d931348ea66c27878454eb9797b Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Mon, 1 Jan 2024 23:47:06 +0100 Subject: [PATCH] helpers: highlightType -> nixvimTypes.highlight --- lib/helpers.nix | 67 ++++++++++++++++++------------------ modules/highlights.nix | 2 +- plugins/colorschemes/ayu.nix | 2 +- 3 files changed, 35 insertions(+), 36 deletions(-) diff --git a/lib/helpers.nix b/lib/helpers.nix index ff2f754c..9a85f4d7 100644 --- a/lib/helpers.nix +++ b/lib/helpers.nix @@ -59,39 +59,6 @@ with lib; rec { emptyTable = {"__empty" = null;}; - highlightType = with lib.types; - submodule { - # Adds flexibility for other keys - freeformType = types.attrs; - - # :help nvim_set_hl() - options = { - fg = mkNullOrOption str "Color for the foreground (color name or '#RRGGBB')."; - bg = mkNullOrOption str "Color for the background (color name or '#RRGGBB')."; - sp = mkNullOrOption str "Special color (color name or '#RRGGBB')."; - blend = mkNullOrOption (numbers.between 0 100) "Integer between 0 and 100."; - bold = mkNullOrOption bool ""; - standout = mkNullOrOption bool ""; - underline = mkNullOrOption bool ""; - undercurl = mkNullOrOption bool ""; - underdouble = mkNullOrOption bool ""; - underdotted = mkNullOrOption bool ""; - underdashed = mkNullOrOption bool ""; - strikethrough = mkNullOrOption bool ""; - italic = mkNullOrOption bool ""; - reverse = mkNullOrOption bool ""; - nocombine = mkNullOrOption bool ""; - link = mkNullOrOption str "Name of another highlight group to link to."; - default = mkNullOrOption bool "Don't override existing definition."; - ctermfg = mkNullOrOption str "Sets foreground of cterm color."; - ctermbg = mkNullOrOption str "Sets background of cterm color."; - cterm = mkNullOrOption attrs '' - cterm attribute map, like |highlight-args|. - If not set, cterm attributes will match those from the attribute map documented above. - ''; - }; - }; - borderType = with lib.types; oneOf [ str @@ -290,7 +257,7 @@ with lib; rec { mkHighlight = default: name: desc: mkNullable - highlightType + nixvimTypes.highlight default ( if desc == "" @@ -413,6 +380,38 @@ with lib; rec { merge = mergeEqualOption; check = isRawType; }; + + highlight = types.submodule { + # Adds flexibility for other keys + freeformType = types.attrs; + + # :help nvim_set_hl() + options = with types; { + fg = mkNullOrOption str "Color for the foreground (color name or '#RRGGBB')."; + bg = mkNullOrOption str "Color for the background (color name or '#RRGGBB')."; + sp = mkNullOrOption str "Special color (color name or '#RRGGBB')."; + blend = mkNullOrOption (numbers.between 0 100) "Integer between 0 and 100."; + bold = mkNullOrOption bool ""; + standout = mkNullOrOption bool ""; + underline = mkNullOrOption bool ""; + undercurl = mkNullOrOption bool ""; + underdouble = mkNullOrOption bool ""; + underdotted = mkNullOrOption bool ""; + underdashed = mkNullOrOption bool ""; + strikethrough = mkNullOrOption bool ""; + italic = mkNullOrOption bool ""; + reverse = mkNullOrOption bool ""; + nocombine = mkNullOrOption bool ""; + link = mkNullOrOption str "Name of another highlight group to link to."; + default = mkNullOrOption bool "Don't override existing definition."; + ctermfg = mkNullOrOption str "Sets foreground of cterm color."; + ctermbg = mkNullOrOption str "Sets background of cterm color."; + cterm = mkNullOrOption attrs '' + cterm attribute map, like |highlight-args|. + If not set, cterm attributes will match those from the attribute map documented above. + ''; + }; + }; } # Allow to do `with nixvimTypes;` instead of `with types;` // types; diff --git a/modules/highlights.nix b/modules/highlights.nix index fada97f8..628ac92d 100644 --- a/modules/highlights.nix +++ b/modules/highlights.nix @@ -7,7 +7,7 @@ with lib; { options = { highlight = mkOption { - type = types.attrsOf helpers.highlightType; + type = types.attrsOf helpers.nixvimTypes.highlight; default = {}; description = "Define highlight groups"; example = '' diff --git a/plugins/colorschemes/ayu.nix b/plugins/colorschemes/ayu.nix index 8b95c04d..11f4198b 100644 --- a/plugins/colorschemes/ayu.nix +++ b/plugins/colorschemes/ayu.nix @@ -25,7 +25,7 @@ in { ( with types; either - (attrsOf helpers.highlightType) + (attrsOf helpers.nixvimTypes.highlight) str ) "{}"