robin/weave

simple neovim wrapper for nix

git clone https://git.robinwobin.dev/robin/weave

robinwrapper: add plugins supportbf40ced

main
1.2 KiB59 linesraw
1{
2  lib,
3
4  plugins,
5  startPlugins,
6  optPlugins,
7  ...
8}:
9let
10  inherit (lib)
11    partition
12    filter
13    concatLists
14    subtractLists
15    unique
16    flatten
17    attrValues
18    pipe
19    isDerivation
20    ;
21
22  partitionPlugins =
23    plugs:
24    let
25      parts = partition (elem: elem.passthru.start or false) plugs;
26    in
27    {
28      start = parts.right;
29      opt = parts.wrong;
30    };
31
32  partitionedPlugins = pipe plugins [
33    attrValues
34    (filter isDerivation)
35    partitionPlugins
36  ];
37
38  # find deps
39  # see https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vim/plugins/utils/vim-utils.nix#L159-L164
40  transitiveClosure =
41    plugin: [ plugin ] ++ (lib.unique (concatLists (map transitiveClosure plugin.dependencies or [ ])));
42  findDependenciesRecursively = plugins: lib.concatMap transitiveClosure plugins;
43
44  start' = flatten [
45    partitionedPlugins.start
46    startPlugins
47  ];
48  opt = flatten [
49    partitionedPlugins.opt
50    optPlugins
51  ];
52
53  depsOfOptionalPlugins = subtractLists opt (findDependenciesRecursively opt);
54  startWithDeps = findDependenciesRecursively start';
55in
56{
57  start = unique (startWithDeps ++ depsOfOptionalPlugins);
58  inherit opt;
59}