From 51e28d415a90f4dc0e64700096086727652b31e2 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 8 Apr 2024 01:36:59 +0300 Subject: [PATCH] lib: move global functions to extended lib --- lib/binds.nix | 3 +-- lib/config.nix | 11 +++++++++++ lib/default.nix | 2 ++ modules/core/build/config.nix | 14 ++++---------- 4 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 lib/config.nix diff --git a/lib/binds.nix b/lib/binds.nix index 57b700e..d42a414 100644 --- a/lib/binds.nix +++ b/lib/binds.nix @@ -66,8 +66,7 @@ mkSetLuaBinding = binding: action: mkLuaBinding binding.value action binding.description; - pushDownDefault = attr: mapAttrs (_name: value: mkDefault value) attr; - # pushDownDefault = attr: self.mapAttrs (name: value: self.mkDefault value) attr; + pushDownDefault = attr: mapAttrs (_: value: mkDefault value) attr; }; in binds diff --git a/lib/config.nix b/lib/config.nix new file mode 100644 index 0000000..a2b8970 --- /dev/null +++ b/lib/config.nix @@ -0,0 +1,11 @@ +{lib}: let + inherit (lib.options) mkOption; + inherit (lib.types) bool; +in { + mkBool = value: description: + mkOption { + type = bool; + default = value; + inherit description; + }; +} diff --git a/lib/default.nix b/lib/default.nix index 333e832..5f0675d 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,5 +1,7 @@ {lib}: { types = import ./types {inherit lib;}; + + config = import ./config.nix {inherit lib;}; binds = import ./binds.nix {inherit lib;}; dag = import ./dag.nix {inherit lib;}; languages = import ./languages.nix {inherit lib;}; diff --git a/modules/core/build/config.nix b/modules/core/build/config.nix index 0a68a81..49c84b5 100644 --- a/modules/core/build/config.nix +++ b/modules/core/build/config.nix @@ -3,10 +3,10 @@ lib, ... }: let - inherit (builtins) attrValues attrNames map mapAttrs toJSON isString concatStringsSep filter; + inherit (builtins) map mapAttrs toJSON filter; inherit (lib.options) mkOption; - inherit (lib.attrsets) filterAttrs getAttrs; - inherit (lib.strings) optionalString; + inherit (lib.attrsets) filterAttrs getAttrs attrValues attrNames; + inherit (lib.strings) optionalString isString concatStringsSep; inherit (lib.misc) mapAttrsFlatten; inherit (lib.trivial) showWarnings; inherit (lib.types) bool str oneOf attrsOf nullOr attrs submodule lines; @@ -15,6 +15,7 @@ inherit (lib.generators) mkLuaInline; inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.vim) valToVim; + inherit (lib.nvim.config) mkBool; cfg = config.vim; @@ -27,13 +28,6 @@ EOF ''; - mkBool = value: description: - mkOption { - type = bool; - default = value; - inherit description; - }; - # Most of the keybindings code is highly inspired by pta2002/nixvim. Thank you! mapConfigOptions = { silent =