Skip to content

Commit ce82e58

Browse files
committed
treewide: use mkAssertions where possible
1 parent 12e658e commit ce82e58

File tree

14 files changed

+96
-106
lines changed

14 files changed

+96
-106
lines changed

plugins/by-name/copilot-lua/default.nix

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,13 @@ lib.nixvim.plugins.mkNeovimPlugin {
176176
};
177177

178178
extraConfig = {
179-
assertions = [
180-
{
181-
assertion = !config.plugins.copilot-vim.enable;
182-
message = ''
183-
You currently have both `copilot-vim` and `copilot-lua` enabled.
184-
Please disable one of them.
185-
'';
186-
}
187-
];
179+
assertions = lib.nixvim.mkAssertions "plugins.copilot-lua" {
180+
assertion = !config.plugins.copilot-vim.enable;
181+
message = ''
182+
You currently have both `copilot-vim` and `copilot-lua` enabled.
183+
Please disable one of them.
184+
'';
185+
};
188186
};
189187

190188
# TODO: introduced 2025-01-07: remove after 25.05

plugins/by-name/git-worktree/default.nix

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ lib.nixvim.plugins.mkNeovimPlugin {
5959
extraConfig =
6060
cfg:
6161
lib.mkIf cfg.enable {
62-
assertions = [
63-
{
64-
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
65-
message = ''Nixvim: The git-worktree telescope integration needs telescope to function as intended'';
66-
}
67-
];
62+
assertions = lib.nixvim.mkAssertions "plugins.git-worktree" {
63+
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
64+
message = ''
65+
You have to enable `plugins.telescope` as `enableTelescope` is activated.
66+
'';
67+
};
6868

6969
extraPackages = [ cfg.gitPackage ];
7070

plugins/by-name/harpoon/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ in
191191
// cfg.extraOptions;
192192
in
193193
mkIf cfg.enable {
194-
assertions = [
194+
assertions = lib.nixvim.mkAssertions "plugins.harpoon" [
195195
{
196196
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
197-
message = ''Nixvim: The harpoon telescope integration needs telescope to function as intended'';
197+
message = "The harpoon telescope integration needs telescope to function as intended.";
198198
}
199199
];
200200

plugins/by-name/lean/default.nix

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -231,29 +231,27 @@ in
231231
config = mkIf cfg.enable {
232232
extraPlugins = [ cfg.package ];
233233

234-
assertions = [
235-
{
236-
assertion =
237-
!(
238-
# leanls lsp server is disabled in nvim-lspconfig
239-
config.plugins.lsp.servers.leanls.enable
240-
# lsp is not (!) disabled in the lean.nvim plugin
241-
&& !(
242-
# lsp is explicitly set to `false`.
243-
(isBool cfg.lsp.enable) && !cfg.lsp.enable
244-
)
245-
);
246-
message = ''
247-
You have not explicitly set `plugins.lean.lsp` to `false` while having `plugins.lsp.servers.leanls.enable` set to `true`.
248-
You need to either
249-
250-
- Remove the configuration in `plugins.lsp.servers.leanls` and move it to `plugins.lean.lsp`.
251-
- Explicitly disable the autoconfiguration of the lsp in the lean.nvim plugin by setting `plugins.lean.lsp` to `false`.
252-
253-
https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#leanls
254-
'';
255-
}
256-
];
234+
assertions = lib.nixvim.mkAssertions "plugins.lean" {
235+
assertion =
236+
!(
237+
# leanls lsp server is disabled in nvim-lspconfig
238+
config.plugins.lsp.servers.leanls.enable
239+
# lsp is not (!) disabled in the lean.nvim plugin
240+
&& !(
241+
# lsp is explicitly set to `false`.
242+
(isBool cfg.lsp.enable) && !cfg.lsp.enable
243+
)
244+
);
245+
message = ''
246+
You have not explicitly set `plugins.lean.lsp` to `false` while having `plugins.lsp.servers.leanls.enable` set to `true`.
247+
You need to either
248+
249+
- Remove the configuration in `plugins.lsp.servers.leanls` and move it to `plugins.lean.lsp`.
250+
- Explicitly disable the autoconfiguration of the lsp in the lean.nvim plugin by setting `plugins.lean.lsp` to `false`.
251+
252+
https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#leanls
253+
'';
254+
};
257255

258256
extraPackages = [ cfg.leanPackage ];
259257

plugins/by-name/mini/default.nix

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,14 @@ lib.nixvim.plugins.mkNeovimPlugin {
9494
callSetup = false;
9595
hasSettings = false;
9696
extraConfig = cfg: {
97-
assertions = [
98-
{
99-
assertion = cfg.mockDevIcons -> cfg.modules ? icons;
100-
message = ''
101-
You have enabled `plugins.mini.mockDevIcons` but have not defined `plugins.mini.modules.icons`.
102-
This setting will have no effect without it.
103-
'';
104-
}
105-
];
97+
assertions = lib.nixvim.mkAssertions "pluhins.mini" {
98+
assertion = cfg.mockDevIcons -> cfg.modules ? icons;
99+
message = ''
100+
You have enabled `plugins.mini.mockDevIcons` but have not defined `plugins.mini.modules.icons`.
101+
This setting will have no effect without it.
102+
'';
103+
};
104+
106105
plugins.mini.luaConfig.content =
107106
lib.foldlAttrs (lines: name: config: ''
108107
${lines}

plugins/by-name/neotest/adapters.nix

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ let
3737
mkIf cfg.enable {
3838
extraPlugins = [ cfg.package ];
3939

40-
assertions = [
41-
{
42-
assertion = config.plugins.neotest.enable;
43-
message = "Nixvim: you have enabled `plugins.neotest.adapters.${name}` but `plugins.neotest.enable` is `false`.";
44-
}
45-
];
40+
assertions = lib.nixvim.mkAssertions "plugins.neotest.adapters.${name}" {
41+
assertion = config.plugins.neotest.enable;
42+
message = ''
43+
You have to enable `plugins.telescope` as `enableTelescope` is activated.
44+
'';
45+
};
4646

4747
warnings = lib.nixvim.mkWarnings "plugins.neotest.adapters.${name}" {
4848
when = !config.plugins.treesitter.enable;

plugins/by-name/none-ls/default.nix

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,16 @@ lib.nixvim.plugins.mkNeovimPlugin {
137137
'';
138138
};
139139

140-
assertions = [
141-
{
142-
assertion = cfg.enableLspFormat -> config.plugins.lsp-format.enable;
143-
message = ''
144-
Nixvim: You have enabled the lsp-format integration with none-ls.
145-
However, you have not enabled `plugins.lsp-format` itself.
146-
Note: `plugins.none-ls.enableLspFormat` is enabled by default when `plugins.lsp-format` is enabled.
147-
`plugins.none-ls.enableLspFormat` definitions: ${lib.options.showDefs options.plugins.none-ls.enableLspFormat.definitionsWithLocations}
148-
'';
149-
}
150-
];
140+
assertions = lib.nixvim.mkAssertions "plugins.none-ls" {
141+
assertion = cfg.enableLspFormat -> config.plugins.lsp-format.enable;
142+
143+
message = ''
144+
You have enabled the lsp-format integration with none-ls.
145+
However, you have not enabled `plugins.lsp-format` itself.
146+
Note: `plugins.none-ls.enableLspFormat` is enabled by default when `plugins.lsp-format` is enabled.
147+
`plugins.none-ls.enableLspFormat` definitions: ${lib.options.showDefs options.plugins.none-ls.enableLspFormat.definitionsWithLocations}
148+
'';
149+
};
151150

152151
# We only do this here because of enableLspFormat
153152
plugins.none-ls.luaConfig.content = ''

plugins/by-name/package-info/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
111111
assertions = lib.nixvim.mkAssertions "plugins.package-info" {
112112
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
113113
message = ''
114-
The telescope integration needs telescope to function as intended.
114+
You have to enable `plugins.telescope` as `enableTelescope` is activated.
115115
'';
116116
};
117117

plugins/by-name/rainbow-delimiters/default.nix

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,15 @@ with lib;
119119
when = !config.plugins.treesitter.enable;
120120
message = "This plugin needs treesitter to function as intended.";
121121
};
122-
assertions = [
123-
{
124-
assertion = (cfg.whitelist == null) || (cfg.blacklist == null);
125-
message = ''
126-
Both `rainbow-delimiters.whitelist` and `rainbow-delimiters.blacklist` should not be
127-
set simultaneously.
128-
Please remove one of them.
129-
'';
130-
}
131-
];
122+
assertions = lib.nixvim.mkAssertions "plugins.rainbow-delimiters" {
123+
assertion = (cfg.whitelist == null) || (cfg.blacklist == null);
124+
125+
message = ''
126+
Both `rainbow-delimiters.whitelist` and `rainbow-delimiters.blacklist` should not be
127+
set simultaneously.
128+
Please remove one of them.
129+
'';
130+
};
132131

133132
extraPlugins = [ cfg.package ];
134133

plugins/by-name/refactoring/default.nix

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ lib.nixvim.plugins.mkNeovimPlugin {
2626
};
2727

2828
extraConfig = cfg: {
29-
assertions = [
30-
{
31-
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
32-
message = ''
33-
Nixvim: You have enabled the `telescope` integration with refactoring-nvim.
34-
However, you have not enabled the `telescope` plugin itself (`plugins.telescope.enable = true`).
35-
'';
36-
}
37-
];
29+
assertions = lib.nixvim.mkAssertions "plugins.refactoring" {
30+
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
31+
32+
message = ''
33+
You have enabled the `telescope` integration with refactoring-nvim.
34+
However, you have not enabled the `telescope` plugin itself (`plugins.telescope.enable = true`).
35+
'';
36+
};
3837

3938
plugins.telescope.enabledExtensions = mkIf cfg.enableTelescope [ "refactoring" ];
4039
};

plugins/by-name/telekasten/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
2727
assertions = lib.nixvim.mkAssertions "plugins.telekasten" {
2828
assertion = config.plugins.telescope.enable;
2929
message = ''
30-
Nixvim (plugins.telekasten): The plugin needs telescope to function as intended.
30+
You have to enable `plugins.telescope` as `enableTelescope` is activated.
3131
'';
3232
};
3333

plugins/by-name/tiny-devicons-auto-colors/default.nix

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,18 @@ lib.nixvim.plugins.mkNeovimPlugin {
9090
};
9191

9292
extraConfig = {
93-
assertions = [
94-
{
95-
assertion =
96-
config.plugins.web-devicons.enable
97-
|| (
98-
config.plugins.mini.enable
99-
&& config.plugins.mini.modules ? icons
100-
&& config.plugins.mini.mockDevIcons
101-
);
102-
message = ''
103-
Nixvim: Either `plugins.web-devicons` or `plugins.mini`* must be enabled to use `tiny-devicons-auto-colors`.
104-
*If using `plugins.mini`, you must enable the `icons` module and the `mockDevIcons` option.
105-
'';
106-
}
107-
];
93+
assertions = lib.nixvim.mkAssertions "plugins.tiny-devicons-auto-colors" {
94+
assertion =
95+
config.plugins.web-devicons.enable
96+
|| (
97+
config.plugins.mini.enable
98+
&& config.plugins.mini.modules ? icons
99+
&& config.plugins.mini.mockDevIcons
100+
);
101+
message = ''
102+
Either `plugins.web-devicons` or `plugins.mini`* must be enabled to use `tiny-devicons-auto-colors`.
103+
*If using `plugins.mini`, you must enable the `icons` module and the `mockDevIcons` option.
104+
'';
105+
};
108106
};
109107
}

plugins/by-name/todo-comments/default.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,18 +414,18 @@ lib.nixvim.plugins.mkNeovimPlugin {
414414
};
415415

416416
extraConfig = cfg: {
417-
assertions = [
417+
assertions = lib.nixvim.mkAssertions "plugins.todo-comments" [
418418
{
419419
assertion = cfg.keymaps.todoTelescope.key or null != null -> config.plugins.telescope.enable;
420420
message = ''
421-
Nixvim(plugins.todo-comments): You have enabled todo-comment's `telescope` integration.
421+
You have enabled todo-comment's `telescope` integration.
422422
However, you have not enabled the `telescope` plugin itself (`plugins.telescope.enable = true`).
423423
'';
424424
}
425425
{
426426
assertion = cfg.keymaps.todoTrouble.key or null != null -> config.plugins.trouble.enable;
427427
message = ''
428-
Nixvim(plugins.todo-comments): You have enabled todo-comment's `trouble` integration.
428+
You have enabled todo-comment's `trouble` integration.
429429
However, you have not enabled the `trouble` plugin itself (`plugins.trouble.enable = true`).
430430
'';
431431
}

plugins/by-name/yanky/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
363363
{
364364
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
365365
message = ''
366-
The telescope integration needs telescope to function as intended
366+
You have to enable `plugins.telescope` as `enableTelescope` is activated.
367367
'';
368368
}
369369
{

0 commit comments

Comments
 (0)