mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-07 07:44:33 +02:00
lib: add applyPrefixToAttrs
This commit is contained in:
parent
e24e40e5f1
commit
1d50fa4f63
4 changed files with 30 additions and 1 deletions
|
@ -67,6 +67,7 @@ lib.fix (
|
|||
;
|
||||
|
||||
inherit (self.utils)
|
||||
applyPrefixToAttrs
|
||||
concatNonEmptyLines
|
||||
emptyTable
|
||||
enableExceptInTests
|
||||
|
|
|
@ -20,6 +20,23 @@ rec {
|
|||
"__empty" = null;
|
||||
};
|
||||
|
||||
/**
|
||||
Add a prefix to the keys of an attrs.
|
||||
|
||||
# Example
|
||||
```nix
|
||||
applyPrefixToAttrs "prefix_" { foo = 1; bar = 2; }
|
||||
=> { prefix_foo = 1; prefix_bar = 2; }
|
||||
```
|
||||
|
||||
# Type
|
||||
|
||||
```
|
||||
applyPrefixToAttrs :: String -> AttrSet -> AttrSet
|
||||
```
|
||||
*/
|
||||
applyPrefixToAttrs = prefix: lib.mapAttrs' (n: lib.nameValuePair (prefix + n));
|
||||
|
||||
/**
|
||||
Turn all the keys of an attrs into raw lua.
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
extraPlugins = extraPlugins ++ [
|
||||
(cfg.packageDecorator cfg.package)
|
||||
];
|
||||
globals = lib.mapAttrs' (n: lib.nameValuePair (globalPrefix + n)) (cfg.settings or { });
|
||||
globals = lib.nixvim.applyPrefixToAttrs globalPrefix (cfg.settings or { });
|
||||
}
|
||||
(lib.optionalAttrs (isColorscheme && (colorscheme != null)) {
|
||||
colorscheme = lib.mkDefault colorscheme;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue