From 6348336db0e0b17ab6d9c73bc8206db84ebf00d1 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Thu, 5 Dec 2024 20:47:26 +0000 Subject: [PATCH] modules/lazyload: init w/ assertion Adds a global lazyloading assertion. No module options yet. --- modules/default.nix | 1 + modules/lazyload.nix | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 modules/lazyload.nix diff --git a/modules/default.nix b/modules/default.nix index 739a30db84..49c2ddf619 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -16,6 +16,7 @@ ./filetype.nix ./highlights.nix ./keymaps.nix + ./lazyload.nix ./lua-loader.nix ./opts.nix ./output.nix diff --git a/modules/lazyload.nix b/modules/lazyload.nix new file mode 100644 index 0000000000..17bb325f9a --- /dev/null +++ b/modules/lazyload.nix @@ -0,0 +1,30 @@ +{ + config, + lib, + ... +}: +let + implementations = [ + "lz-n" + "lazy" + ]; +in +{ + config = { + assertions = + let + enabled = builtins.filter (x: config.plugins.${x}.enable) implementations; + count = builtins.length enabled; + in + [ + { + assertion = count < 2; + message = '' + You have multiple lazy-loaders enabled: + ${lib.concatImapStringsSep "\n" (i: x: "${toString i}. plugins.${x}") enabled} + Please ensure only one is enabled at a time. + ''; + } + ]; + }; +}