diff --git a/lib/types/default.nix b/lib/types/default.nix index d7ddd240..70ca6bef 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -6,12 +6,10 @@ typesDag = import ./dag.nix {inherit lib;}; typesPlugin = import ./plugins.nix {inherit inputs lib;}; typesLanguage = import ./languages.nix {inherit lib;}; - typesCustom = import ./custom.nix {inherit lib;}; - typesTheme = import ./theme.nix {inherit lib;}; + typesTypes = import ./types.nix {inherit lib;}; in { inherit (typesDag) dagOf; inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType; inherit (typesLanguage) diagnostics mkGrammarOption; - inherit (typesCustom) anythingConcatLists char; - inherit (typesTheme) hexColorType; + inherit (typesTypes) anythingConcatLists char hexColor; } diff --git a/lib/types/theme.nix b/lib/types/theme.nix deleted file mode 100644 index 3ba2f489..00000000 --- a/lib/types/theme.nix +++ /dev/null @@ -1,14 +0,0 @@ -{lib}: let - inherit (lib.strings) isString; - inherit (lib.types) mkOptionType; - inherit (builtins) match; - # This was almost entirely taken from raf himself. -in { - hexColorType = mkOptionType { - name = "hex-color"; - descriptionClass = "noun"; - description = "RGB color in hex format"; - # Check to determine wether the provided color is base16-valid - check = x: isString x && (match "#[0-9a-fA-F]{6}" x) != null; - }; -} diff --git a/lib/types/custom.nix b/lib/types/types.nix similarity index 89% rename from lib/types/custom.nix rename to lib/types/types.nix index a94735c5..52358bf9 100644 --- a/lib/types/custom.nix +++ b/lib/types/types.nix @@ -1,8 +1,9 @@ {lib}: let inherit (lib) isStringLike showOption showFiles getFiles mergeOneOption mergeEqualOption mkOptionType; + inherit (lib.strings) isString hasPrefix; inherit (lib.types) anything attrsOf; inherit (lib.nvim.types) anythingConcatLists; - inherit (builtins) typeOf isAttrs any head concatLists stringLength; + inherit (builtins) typeOf isAttrs any head concatLists stringLength match; in { # HACK: Does this break anything in our case? # A modified version of the nixpkgs anything type that concatenates lists @@ -58,4 +59,11 @@ in { check = value: stringLength value < 2; merge = mergeEqualOption; }; + + hexColor = mkOptionType { + name = "hex-color"; + descriptionClass = "noun"; + description = "RGB color in hex format"; + check = v: isString v && (match "#?[0-9a-fA-F]{6}" v) != null; + }; }