summaryrefslogtreecommitdiffstats
path: root/pkgs/test/vim/default.nix
blob: 296409a7e035e056c83a7839bea3175a587cf91d (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
46
47
48
49
50
51
52
53
54
55
56
{
  lib,
  vimUtils,
  vim-full,
  vimPlugins,

  pkgs,
}:
lib.recurseIntoAttrs {
  vim_empty_config = vimUtils.vimrcFile {
    beforePlugins = "";
    customRC = "";
  };

  ### vim tests
  ##################

  test_vim_with_vim_nix_using_plug = vim-full.customize {
    name = "vim-with-vim-addon-nix-using-plug";
    vimrcConfig.plug.plugins = with vimPlugins; [ vim-nix ];
  };

  test_vim_with_vim_nix = vim-full.customize {
    name = "vim-with-vim-addon-nix";
    vimrcConfig.packages.myVimPackage.start = with vimPlugins; [ vim-nix ];
  };

  # test that all vimPlugins have `passthru.vimPlugin = true`
  test-all-plugins-have-vimPlugin-true =
    let
      # we remove aliases as they are irrelevant here and cause warning when evaling this test
      pkgsNoAliases = (
        pkgs.extend (
          self: prev: {
            config = prev.config // {
              allowAliases = false;
            };
          }
        )
      );
      vimPluginsNoAliases = pkgsNoAliases.vimPlugins;
    in
    assert
      lib.attrNames (
        lib.filterAttrs (
          name: elem:
          # exclude non-plugins
          lib.isDerivation elem
          && name != "corePlugins"
          # only plugins that don't have `vimPlugin = true`
          && elem.passthru.vimPlugin or false != true
        ) vimPluginsNoAliases
      ) == [ ];
    # testing is done during evaluation above so this derivation is irrelevant
    vim-full;
}