robin/weave
simple neovim wrapper for nix
git clone https://git.robinwobin.dev/robin/weave
bf40ced
main
1{ 2lib , 3 4plugins , 5startPlugins , 6optPlugins , 7 ... 8} : 9let 10inherit ( lib ) 11partition 12filter 13concatLists 14subtractLists 15unique 16flatten 17attrValues 18pipe 19isDerivation 20; 21 22partitionPlugins = 23plugs : 24let 25parts = partition ( elem :elem . passthru . start or false ) plugs ; 26in 27{ 28start = parts . right ; 29opt = parts . wrong ; 30}; 31 32partitionedPlugins = pipe plugins [ 33attrValues 34( filter isDerivation ) 35partitionPlugins 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 40transitiveClosure = 41plugin :[ plugin ] ++ ( lib . unique ( concatLists ( map transitiveClosure plugin . dependencies or [ ]))); 42findDependenciesRecursively = plugins :lib . concatMap transitiveClosure plugins ; 43 44start' = flatten [ 45partitionedPlugins . start 46startPlugins 47]; 48opt = flatten [ 49partitionedPlugins . opt 50optPlugins 51]; 52 53depsOfOptionalPlugins = subtractLists opt ( findDependenciesRecursively opt ); 54startWithDeps = findDependenciesRecursively start' ; 55in 56{ 57start = unique ( startWithDeps ++ depsOfOptionalPlugins ); 58inherit opt ; 59}