mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-24 04:09:49 +01:00
treewide: move resolveDag to lib
This commit is contained in:
parent
714f006a34
commit
4236894566
2 changed files with 24 additions and 24 deletions
23
lib/dag.nix
23
lib/dag.nix
|
@ -8,10 +8,10 @@
|
|||
# - the addition of the function `entryBefore` indicating a "wanted
|
||||
# by" relationship.
|
||||
{lib}: let
|
||||
inherit (builtins) isAttrs attrValues attrNames elem all head tail length;
|
||||
inherit (builtins) isAttrs attrValues attrNames elem all head tail length toJSON isString;
|
||||
inherit (lib.attrsets) filterAttrs mapAttrs;
|
||||
inherit (lib.lists) toposort;
|
||||
inherit (lib.nvim.dag) empty isEntry entryBetween entryAfter entriesBetween;
|
||||
inherit (lib.nvim.dag) empty isEntry entryBetween entryAfter entriesBetween entryAnywhere topoSort;
|
||||
in {
|
||||
empty = {};
|
||||
|
||||
|
@ -146,4 +146,23 @@ in {
|
|||
-- SECTION: ${section.name}
|
||||
${section.data}
|
||||
'';
|
||||
|
||||
resolveDag = {
|
||||
name,
|
||||
dag,
|
||||
mapResult,
|
||||
}: let
|
||||
# When the value is a string, default it to dag.entryAnywhere
|
||||
finalDag = mapAttrs (_: value:
|
||||
if isString value
|
||||
then entryAnywhere value
|
||||
else value)
|
||||
dag;
|
||||
sortedDag = topoSort finalDag;
|
||||
result =
|
||||
if sortedDag ? result
|
||||
then mapResult sortedDag.result
|
||||
else abort ("Dependency cycle in ${name}: " + toJSON sortedDag);
|
||||
in
|
||||
result;
|
||||
}
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) map mapAttrs toJSON filter;
|
||||
inherit (builtins) map mapAttrs filter;
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.attrsets) filterAttrs getAttrs attrValues attrNames;
|
||||
inherit (lib.strings) isString concatLines concatMapStringsSep;
|
||||
inherit (lib.strings) concatLines concatMapStringsSep;
|
||||
inherit (lib.misc) mapAttrsFlatten;
|
||||
inherit (lib.trivial) showWarnings;
|
||||
inherit (lib.types) str nullOr;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.dag) entryAnywhere entryAfter topoSort mkLuarcSection;
|
||||
inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.config) mkBool;
|
||||
|
||||
|
@ -104,25 +104,6 @@ in {
|
|||
omap = toLuaBindings "o" config.vim.maps.operator;
|
||||
icmap = toLuaBindings "ic" config.vim.maps.insertCommand;
|
||||
|
||||
resolveDag = {
|
||||
name,
|
||||
dag,
|
||||
mapResult,
|
||||
}: let
|
||||
# When the value is a string, default it to dag.entryAnywhere
|
||||
finalDag = mapAttrs (_: value:
|
||||
if isString value
|
||||
then entryAnywhere value
|
||||
else value)
|
||||
dag;
|
||||
sortedDag = topoSort finalDag;
|
||||
result =
|
||||
if sortedDag ? result
|
||||
then mapResult sortedDag.result
|
||||
else abort ("Dependency cycle in ${name}: " + toJSON sortedDag);
|
||||
in
|
||||
result;
|
||||
|
||||
extraPluginConfigs = resolveDag {
|
||||
name = "extra plugins config";
|
||||
dag = mapAttrs (_: value: entryAfter value.after value.setup) cfg.extraPlugins;
|
||||
|
|
Loading…
Reference in a new issue