Skip to content

Commit bc75aa0

Browse files
committed
lib/neovim-plugin: lazy prefer opts over config
Upstream documentation recommends just providing the opts instead of the function call explicitly.
1 parent 1a4f580 commit bc75aa0

File tree

2 files changed

+5
-42
lines changed

2 files changed

+5
-42
lines changed

lib/neovim-plugin.nix

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,11 @@
203203
name = originalName;
204204
main = luaName;
205205
pkg = cfg.package;
206-
# Use provided config, otherwise fallback to normal lua content
207-
config =
208-
cfg.lazyLoad.settings.config or
209-
# We need to wrap it in a function so it doesn't execute immediately
210-
("function()\n " + cfg.luaConfig.content + " \nend");
206+
# Use provided opts, otherwise fallback to settings
207+
opts = cfg.lazyLoad.settings.opts or cfg.settings;
211208
}
212209
// (lib.removeAttrs cfg.lazyLoad.settings [
213-
"config"
210+
"opts"
214211
])
215212
)
216213
];

tests/test-sources/plugins/lazyloading/lazy.nix

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
plugins = config.plugins.lazy.plugins or [ ];
4040
plugin = if builtins.length plugins > 0 then builtins.head plugins else null;
4141
in
42-
plugin != null && lib.hasInfix config.plugins.neotest.luaConfig.content plugin.config.__raw;
43-
message = "`lazy.plugins[0].after` should have contained `neotest` lua content.";
42+
plugin != null && config.plugins.neotest.settings == plugin.opts;
43+
message = "`lazy.plugins[0].opts` should have contained `neotest` settings.";
4444
}
4545
];
4646
};
@@ -102,38 +102,4 @@
102102
}
103103
];
104104
};
105-
wrap-functionless-luaConfig =
106-
{ config, ... }:
107-
{
108-
plugins = {
109-
lazy = {
110-
enable = true;
111-
};
112-
web-devicons.enable = false;
113-
telescope = {
114-
enable = true;
115-
lazyLoad = {
116-
enable = true;
117-
settings = {
118-
cmd = [ "Telescope" ];
119-
};
120-
};
121-
};
122-
};
123-
124-
assertions = [
125-
{
126-
assertion = (builtins.length config.plugins.lazy.plugins) == 1;
127-
message = "`lazy.plugins` should have contained a single plugin configuration, but contained ${builtins.toJSON config.plugins.lz-n.plugins}";
128-
}
129-
{
130-
assertion =
131-
let
132-
plugin = builtins.head config.plugins.lazy.plugins;
133-
in
134-
plugin.config.__raw == "function()\n " + config.plugins.telescope.luaConfig.content + " \nend";
135-
message = "`lazy.plugins[0].config` should have contained a function wrapped `telescope` lua content.";
136-
}
137-
];
138-
};
139105
}

0 commit comments

Comments
 (0)