mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-01 04:44:31 +02:00
lib/pkg-lists: move to common location
Extract the helper functions defined in `efmls-configs-pkgs` to a common location where they can also be used by none-ls's package list.
This commit is contained in:
parent
d2aad1071f
commit
cdb2e79e51
3 changed files with 49 additions and 41 deletions
23
lib/pkg-lists.nix
Normal file
23
lib/pkg-lists.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
# This file isn't (currently) part of `lib.nixvim`, but is used directly by `efmls` and `none-ls` pkg lists
|
||||
lib: rec {
|
||||
# Produces an attrset of { ${name} = name; }
|
||||
topLevel = names: lib.genAttrs names lib.id;
|
||||
|
||||
# Produces an attrset of { ${name} = null; }
|
||||
nullAttrs = names: lib.genAttrs names (_: null);
|
||||
|
||||
# Produces an attrset of { ${name} = [ scope name ]; }
|
||||
# Where the "scope" is the (nested) attr names,
|
||||
# and "name" is the value.
|
||||
# If the name value is a list, it will be expanded into multiple attrs.
|
||||
scoped = lib.concatMapAttrs (
|
||||
scope: v:
|
||||
if builtins.isAttrs v then
|
||||
lib.mapAttrs (_: loc: [ scope ] ++ loc) (scoped v)
|
||||
else
|
||||
lib.genAttrs (lib.toList v) (name: [
|
||||
scope
|
||||
name
|
||||
])
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue