summaryrefslogtreecommitdiffstats
path: root/modules/plugins/dashboard/alpha/config.nix
blob: 6c57b15a4dd3081281df69420bcd71fd312e501e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{
  config,
  lib,
  ...
}: let
  inherit (lib.modules) mkIf;

  cfg = config.vim.dashboard.alpha;
  themeDefined = cfg.theme != null;
  layoutDefined = cfg.layout != [];
in {
  config = mkIf cfg.enable {
    vim = {
      visuals.nvim-web-devicons.enable = true;

      lazy.plugins.alpha-nvim = {
        package = "alpha-nvim";
        setupModule = "alpha";
        setupOpts =
          if themeDefined
          then lib.generators.mkLuaInline "require'alpha.themes.${cfg.theme}'.config"
          else {
            inherit (cfg) layout opts;
          };
        event = ["VimEnter"];
        cmd = ["Alpha" "AlphaRedraw" "AlphaRemap"];
      };
    };

    assertions = [
      {
        assertion = themeDefined || layoutDefined;
        message = ''
          One of 'theme' or 'layout' should be defined in Alpha configuration.
        '';
      }
      {
        assertion = !(themeDefined && layoutDefined);
        message = ''
          'theme' and 'layout' cannot be defined at the same time.
        '';
      }
    ];
  };
}