From 791e32ed3dc26221f53cee00b8d6a24d8fb85dfe Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Thu, 10 Aug 2023 12:08:41 +0200 Subject: [PATCH] colorschemes/ayu: add plugin + test --- plugins/colorschemes/ayu.nix | 61 +++++++++++++++++++ plugins/default.nix | 1 + .../test-sources/plugins/colorschemes/ayu.nix | 14 +++++ 3 files changed, 76 insertions(+) create mode 100644 plugins/colorschemes/ayu.nix create mode 100644 tests/test-sources/plugins/colorschemes/ayu.nix diff --git a/plugins/colorschemes/ayu.nix b/plugins/colorschemes/ayu.nix new file mode 100644 index 00000000..23a3f0fa --- /dev/null +++ b/plugins/colorschemes/ayu.nix @@ -0,0 +1,61 @@ +{ + pkgs, + config, + lib, + ... +} @ args: +with lib; let + cfg = config.colorschemes.ayu; + helpers = import ../helpers.nix args; +in { + options = { + colorschemes.ayu = + helpers.extraOptionsOptions + // { + enable = mkEnableOption "ayu"; + + package = helpers.mkPackageOption "ayu" pkgs.vimPlugins.neovim-ayu; + + mirage = helpers.defaultNullOpts.mkBool false '' + Set to `true` to use `mirage` variant instead of `dark` for dark background. + ''; + + overrides = + helpers.defaultNullOpts.mkNullable + ( + with types; + either + (attrsOf helpers.highlightType) + str + ) + "{}" + '' + A dictionary of group names, each associated with a dictionary of parameters + (`bg`, `fg`, `sp` and `style`) and colors in hex. + + Alternatively, `overrides` can be a function that returns a dictionary of the same + format. + You can use the function to override based on a dynamic condition, such as the value of + `background`. + ''; + }; + }; + + config = let + setupOptions = with cfg; + { + overrides = + if isString overrides + then helpers.mkRaw overrides + else overrides; + } + // cfg.extraOptions; + in + mkIf cfg.enable { + extraPlugins = [cfg.package]; + + extraConfigLuaPre = '' + require("ayu").setup(${helpers.toLuaObject setupOptions}) + ''; + }; +} diff --git a/plugins/default.nix b/plugins/default.nix index 486ec867..3f6b696a 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -3,6 +3,7 @@ ./bufferlines/barbar.nix ./bufferlines/bufferline.nix + ./colorschemes/ayu.nix ./colorschemes/base16.nix ./colorschemes/gruvbox.nix ./colorschemes/kanagawa.nix diff --git a/tests/test-sources/plugins/colorschemes/ayu.nix b/tests/test-sources/plugins/colorschemes/ayu.nix new file mode 100644 index 00000000..49c86ba9 --- /dev/null +++ b/tests/test-sources/plugins/colorschemes/ayu.nix @@ -0,0 +1,14 @@ +{ + empty = { + colorschemes.ayu.enable = true; + }; + + defaults = { + colorschemes.ayu = { + enable = true; + + mirage = false; + overrides = {}; + }; + }; +}