Skip to content

Commit 832693b

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 1b0d3e7 commit 832693b

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
@@ -201,14 +201,11 @@
201201
name = originalName;
202202
main = luaName;
203203
pkg = cfg.package;
204-
# Use provided config, otherwise fallback to normal lua content
205-
config =
206-
cfg.lazyLoad.settings.config or
207-
# We need to wrap it in a function so it doesn't execute immediately
208-
("function()\n " + cfg.luaConfig.content + " \nend");
204+
# Use provided opts, otherwise fallback to settings
205+
opts = cfg.lazyLoad.settings.opts or cfg.settings;
209206
}
210207
// (lib.removeAttrs cfg.lazyLoad.settings [
211-
"config"
208+
"opts"
212209
])
213210
)
214211
];

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)