Skip to content

Commit

Permalink
plugins/alpha: use iconsPackage
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman committed Aug 29, 2024
1 parent f2ef292 commit 0db6e86
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
26 changes: 24 additions & 2 deletions plugins/utils/alpha.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
lib,
helpers,
config,
options,
pkgs,
...
}:
Expand Down Expand Up @@ -55,10 +56,16 @@ in

package = helpers.mkPluginPackageOption "alpha-nvim" pkgs.vimPlugins.alpha-nvim;

# TODO: deprecated 2024-08-29 remove after 24.11
iconsEnabled = mkOption {
type = types.bool;
description = "Toggle icon support. Installs nvim-web-devicons.";
default = true;
visible = false;
};

iconsPackage = helpers.mkPackageOption {
name = "nvim-web-devicons";
default = pkgs.vimPlugins.nvim-web-devicons;
};

theme = mkOption {
Expand Down Expand Up @@ -139,9 +146,24 @@ in
let
layoutDefined = cfg.layout != [ ];
themeDefined = cfg.theme != null;

opt = options.plugins.alpha;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ] ++ (optional cfg.iconsEnabled pkgs.vimPlugins.nvim-web-devicons);
# TODO: deprecated 2024-08-29 remove after 24.11
warnings = lib.mkIf opt.iconsEnabled.isDefined [
''
nixvim (plugins.alpha):
The option definition `plugins.alpha.iconsEnabled' in ${showFiles opt.iconsEnabled.files} has been deprecated; please remove it.
You should use `plugins.alpha.iconsPackage' instead.
''
];

extraPlugins =
[ cfg.package ]
++ lib.optional (
cfg.iconsPackage != null && (opt.iconsEnabled.isDefined && cfg.iconsEnabled)
) cfg.iconsPackage;

assertions = [
{
Expand Down
9 changes: 8 additions & 1 deletion tests/test-sources/plugins/utils/alpha.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
plugins.alpha = {
enable = true;

iconsEnabled = true;
layout = [
{
type = "padding";
Expand Down Expand Up @@ -100,4 +99,12 @@
};
};
};

no-packages = {
plugins.alpha = {
enable = true;
theme = "dashboard";
iconsPackage = null;
};
};
}

0 comments on commit 0db6e86

Please sign in to comment.