Skip to content

Commit

Permalink
helpers/vim-plugin/mkVimPlugin: add a colorscheme argument and factor…
Browse files Browse the repository at this point in the history
… out logic
  • Loading branch information
GaetanLepage committed Mar 12, 2024
1 parent 3c9a4b6 commit 6010109
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 11 additions & 1 deletion lib/vim-plugin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
with lib; {
mkVimPlugin = config: {
name,
namespace ? "plugins",
colorscheme ? false,
url ?
if defaultPackage != null
then defaultPackage.meta.homepage
Expand All @@ -29,6 +29,11 @@ with lib; {
extraPlugins ? [],
extraPackages ? [],
}: let
namespace =
if colorscheme
then "colorschemes"
else "plugins";

cfg = config.${namespace}.${name};

# TODO support nested options!
Expand Down Expand Up @@ -143,6 +148,11 @@ with lib; {
# does this evaluate package? it would not be desired to evaluate package if we use another package.
extraPlugins = extraPlugins ++ optional (defaultPackage != null) cfg.package;
}
(optionalAttrs colorscheme {
# We use `mkDefault` here to let individual plugins override this option.
# For instance, setting it to `null` a specific way of setting the coloscheme.
colorscheme = lib.mkDefault name;
})
(extraConfig cfg)
]
);
Expand Down
6 changes: 1 addition & 5 deletions plugins/colorschemes/nord.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
...
}:
helpers.vim-plugin.mkVimPlugin config {
namespace = "colorschemes";
name = "nord";
colorscheme = true;
originalName = "nord.nvim";
defaultPackage = pkgs.vimPlugins.nord-nvim;
globalPrefix = "nord_";
Expand Down Expand Up @@ -61,8 +61,4 @@ helpers.vim-plugin.mkVimPlugin config {
disable_background = true;
italic = false;
};

extraConfig = cfg: {
colorscheme = "nord";
};
}

0 comments on commit 6010109

Please sign in to comment.