Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman committed Dec 5, 2024
1 parent e92a729 commit 7bd6017
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 8 deletions.
13 changes: 6 additions & 7 deletions lib/neovim-plugin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,10 @@

lazyLoad = lib.nixvim.mkLazyLoadOption {
inherit originalName;
lazyLoadDefaults = lib.optionalAttrs (isColorscheme && colorscheme != null) {
backendSettings = { inherit colorscheme; };
enable = lib.mkDefault (
lib.filterAttrs (name: value: !(lib.elem name [ "colorscheme" ])) cfg.lazyLoad.backendSettings
!= { }
);
lazyLoadDefaults = {
# FIXME: infinite recursion
# enable = lib.mkDefault (cfg.lazyLoad.backendSettings != { });
backendSettings = lib.mkIf (isColorscheme && colorscheme != null) { inherit colorscheme; };
};
};
}
Expand Down Expand Up @@ -184,7 +182,8 @@
if cfg.lazyLoad.backendSettings.after != null then
cfg.lazyLoad.backendSettings.after
else
cfg.luaConfig.content;
# We need to wrap it in a function so it doesn't execute immediately
"function()\n " + cfg.luaConfig.content + " \nend";
inherit (cfg.lazyLoad.backendSettings)
enabled
priority
Expand Down
69 changes: 68 additions & 1 deletion tests/test-sources/plugins/lazy-load.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
plugins = {
codesnap = {
enable = true;
lazyLoad.enable = true;
# FIXME: shouldn't cause double entries
# lazyLoad.enable = true;
};
lz-n = {
enable = true;
Expand Down Expand Up @@ -146,4 +147,70 @@
}
];
};

# FIXME:
# lazy-load-enabled-automatically =
# { config, ... }:
# {
# plugins = {
# lz-n = {
# enable = true;
# };
# neotest = {
# enable = true;
# lazyLoad = {
# # NOTE: not setting lazyLoad.enable
# backendSettings = {
# keys = [
# {
# __unkeyed-1 = "<leader>nt";
# __unkeyed-3 = "<CMD>Neotest summary<CR>";
# desc = "Summary toggle";
# }
# ];
# };
# };
# };
# };
#
# assertions = [
# {
# assertion = (builtins.length config.plugins.lz-n.plugins) == 1;
# message = "`lz-n.plugins` should have contained a single plugin configuration, but contained ${builtins.toJSON config.plugins.lz-n.plugins}";
# }
# {
# assertion =
# let
# plugin = builtins.head config.plugins.lz-n.plugins;
# keys = if builtins.isList plugin.keys then plugin.keys else [ ];
# in
# (builtins.length keys) == 1;
# message = "`lz-n.plugins[0].keys` should have contained a configuration.";
# }
# ];
# };

wrap-functionless-luaConfig =
{ config, ... }:
{
plugins = {
lz-n = {
enable = true;
};
web-devicons.enable = false;
telescope = {
enable = true;
lazyLoad = {
enable = true;
};
};
};

assertions = [
{
assertion = (builtins.length config.plugins.lz-n.plugins) == 1;
message = "`lz-n.plugins` should have contained a single plugin configuration, but contained ${builtins.toJSON config.plugins.lz-n.plugins}";
}
];
};
}

0 comments on commit 7bd6017

Please sign in to comment.