Skip to content

Commit 12e658e

Browse files
committed
treewide: use mkWarnings where possible
1 parent abba4af commit 12e658e

File tree

34 files changed

+309
-225
lines changed

34 files changed

+309
-225
lines changed

modules/lazyload.nix

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ in
4545
) (builtins.attrNames config.plugins);
4646
count = builtins.length pluginsWithLazyLoad;
4747
in
48-
lib.optionals (count > 0 && !config.plugins.lz-n.enable) [
49-
''
48+
lib.nixvim.mkWarnings "lazy loading" {
49+
when = count > 0 && !config.plugins.lz-n.enable;
50+
51+
message = ''
5052
You have enabled lazy loading support for the following plugins but have not enabled a lazy loading provider.
5153
${lib.concatImapStringsSep "\n" (i: x: "${toString i}. plugins.${x}") pluginsWithLazyLoad}
5254
5355
Currently supported lazy providers:
5456
- lz-n
55-
''
56-
];
57+
'';
58+
};
5759
};
5860
}

plugins/by-name/auto-save/default.nix

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,13 @@ lib.nixvim.plugins.mkNeovimPlugin {
166166
]
167167
];
168168
in
169-
lib.optional (definedOpts != [ ]) ''
170-
Nixvim(plugins.auto-save): The following settings options are no longer supported.
171-
Check the plugin documentation for more details.:
172-
${lib.concatMapStringsSep "\n" (opt: " - ${lib.showOption (lib.toList opt)}") definedOpts}
173-
'';
169+
lib.nixvim.mkWarnings "plugins.auto-save" {
170+
when = definedOpts != [ ];
171+
message = ''
172+
The following settings options are no longer supported.
173+
Check the plugin documentation for more details.:
174+
${lib.concatMapStringsSep "\n" (opt: " - ${lib.showOption (lib.toList opt)}") definedOpts}
175+
'';
176+
};
174177
};
175178
}

plugins/by-name/blink-cmp-copilot/default.nix

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,23 @@ lib.nixvim.plugins.mkNeovimPlugin {
5050
copilot-lua-cfg = config.plugins.copilot-lua.settings;
5151
isEnabled = b: builtins.isBool b && b;
5252
in
53-
lib.optionals (isEnabled copilot-lua-cfg.suggestion.enabled) [
54-
''
55-
It is recommended to disable copilot's `suggestion` module, as it can interfere with
56-
completions properly appearing in blink-cmp-copilot.
57-
''
58-
]
59-
++ lib.optionals (isEnabled copilot-lua-cfg.panel.enabled) [
60-
''
61-
It is recommended to disable copilot's `panel` module, as it can interfere with completions
62-
properly appearing in blink-cmp-copilot.
63-
''
53+
lib.nixvim.mkWarnings "plugins.blink-cmp-copilot" [
54+
{
55+
when = isEnabled copilot-lua-cfg.suggestion.enabled;
56+
message = ''
57+
It is recommended to disable copilot's `suggestion` module, as it can interfere with
58+
completions properly appearing in blink-cmp-copilot.
59+
'';
60+
}
61+
{
62+
when = isEnabled copilot-lua-cfg.panel.enabled;
63+
message = ''
64+
It is recommended to disable copilot's `panel` module, as it can interfere with completions
65+
properly appearing in blink-cmp-copilot.
66+
'';
67+
}
6468
];
69+
6570
plugins.copilot-lua.enable = lib.mkDefault true;
6671
};
6772
}

plugins/by-name/blink-cmp/default.nix

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ lib.nixvim.plugins.mkNeovimPlugin {
4444
};
4545

4646
extraConfig = cfg: {
47-
warnings = lib.optional (cfg.settings ? documentation) ''
48-
Nixvim(plugins.blink): `settings.documentation` does not correspond to a known setting, use `settings.windows.documentation` instead.
49-
'';
47+
warnings = lib.nixvim.mkWarnings "plugins.blink" {
48+
when = cfg.settings ? documentation;
49+
message = ''
50+
`settings.documentation` does not correspond to a known setting, use `settings.windows.documentation` instead.
51+
'';
52+
};
5053
};
5154
}

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,22 @@ lib.nixvim.plugins.mkNeovimPlugin {
6060
copilot-lua-cfg = config.plugins.copilot-lua.settings;
6161
isEnabled = b: (lib.isBool b && b);
6262
in
63-
lib.optional (isEnabled copilot-lua-cfg.suggestion.enabled) ''
64-
It is recommended to disable copilot's `suggestion` module, as it can interfere with
65-
completions properly appearing in copilot-cmp.
66-
''
67-
++ lib.optional (isEnabled copilot-lua-cfg.panel.enabled) ''
68-
It is recommended to disable copilot's `panel` module, as it can interfere with completions
69-
properly appearing in copilot-cmp.
70-
'';
63+
lib.nixvim.mkWarnings "plugins.copilot-cmp" [
64+
{
65+
when = isEnabled copilot-lua-cfg.suggestion.enabled;
66+
message = ''
67+
It is recommended to disable copilot's `suggestion` module, as it can interfere with
68+
completions properly appearing in copilot-cmp.
69+
'';
70+
}
71+
{
72+
when = isEnabled copilot-lua-cfg.panel.enabled;
73+
message = ''
74+
It is recommended to disable copilot's `panel` module, as it can interfere with completions
75+
properly appearing in copilot-cmp.
76+
'';
77+
}
78+
];
7179

7280
plugins.copilot-lua.enable = lib.mkDefault true;
7381
};

plugins/by-name/fidget/default.nix

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -470,16 +470,16 @@ lib.nixvim.plugins.mkNeovimPlugin {
470470
};
471471

472472
extraConfig = cfg: {
473-
warnings =
474-
lib.optionals
475-
(
476-
(builtins.isBool cfg.settings.integration.nvim-tree.enable)
477-
&& cfg.settings.integration.nvim-tree.enable
478-
&& !config.plugins.nvim-tree.enable
479-
)
480-
[
481-
"Nixvim(plugins.fidget): You have set `plugins.fidget.settings.integrations.nvim-tree.enable` to true but have not enabled `plugins.nvim-tree`."
482-
];
473+
warnings = lib.nixvim.mkWarnings "plugins.fidget" {
474+
when =
475+
(builtins.isBool cfg.settings.integration.nvim-tree.enable)
476+
&& cfg.settings.integration.nvim-tree.enable
477+
&& !config.plugins.nvim-tree.enable;
478+
479+
message = ''
480+
You have set `plugins.fidget.settings.integrations.nvim-tree.enable` to true but have not enabled `plugins.nvim-tree`.
481+
'';
482+
};
483483
};
484484

485485
inherit (import ./deprecations.nix { inherit lib; }) imports optionsRenamedToSettings;

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,14 @@ lib.nixvim.plugins.mkNeovimPlugin {
105105

106106
extraConfig = cfg: opts: {
107107
# TODO: deprecated 2024-08-29 remove after 24.11
108-
warnings = lib.optionals opts.iconsEnabled.isDefined [
109-
''
108+
warnings = lib.nixvim.mkWarnings "plugins.fzf-lua" {
109+
when = opts.iconsEnabled.isDefined;
110+
111+
message = ''
110112
The option definition `plugins.fzf-lua.iconsEnabled' in ${lib.showFiles opts.iconsEnabled.files} has been deprecated; please remove it.
111-
''
112-
];
113+
'';
114+
};
115+
113116
# TODO: added 2024-09-20 remove after 24.11
114117
plugins.web-devicons =
115118
lib.mkIf

plugins/by-name/hmts/default.nix

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ lib.nixvim.plugins.mkNeovimPlugin {
1414
hasSettings = false;
1515
hasLuaConfig = false;
1616
extraConfig = {
17-
warnings = lib.optional (
18-
!config.plugins.treesitter.enable
19-
) "Nixvim: hmts needs treesitter to function as intended";
17+
warnings = lib.nixvim.mkWarnings "plugins.hmts" {
18+
when = !config.plugins.treesitter.enable;
19+
message = "hmts needs treesitter to function as intended";
20+
};
2021
};
2122
}

plugins/by-name/lazydev/default.nix

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -135,33 +135,28 @@ lib.nixvim.plugins.mkNeovimPlugin {
135135
};
136136

137137
extraConfig = cfg: {
138-
warnings =
139-
lib.optionals
140-
(
138+
warnings = lib.nixvim.mkWarnings "plugins.lazydev" [
139+
{
140+
when =
141141
builtins.isBool cfg.settings.integrations.cmp
142142
&& !config.plugins.cmp.enable
143-
&& cfg.settings.integrations.cmp
144-
)
145-
[ "Nixvim(plugins.lazydev): you have enabled nvim-cmp integration but plugins.cmp is not enabled." ]
146-
++
147-
lib.optionals
148-
(
149-
builtins.isBool cfg.settings.integrations.lspconfig
150-
&& !config.plugins.lsp.enable
151-
&& cfg.settings.integrations.lspconfig
152-
)
153-
[
154-
"Nixvim(plugins.lazydev): you have enabled lspconfig integration but plugins.lsp is not enabled."
155-
]
156-
++
157-
lib.optionals
158-
(
159-
builtins.isBool cfg.settings.integrations.coq
160-
&& !config.plugins.coq-nvim.enable
161-
&& cfg.settings.integrations.coq
162-
)
163-
[
164-
"Nixvim(plugins.lazydev): you have enabled coq integration but plugins.coq-nvim is not enabled."
165-
];
143+
&& cfg.settings.integrations.cmp;
144+
message = "You have enabled nvim-cmp integration but plugins.cmp is not enabled.";
145+
}
146+
{
147+
when =
148+
builtins.isBool cfg.settings.integrations.lspconfig
149+
&& !config.plugins.lsp.enable
150+
&& cfg.settings.integrations.lspconfig;
151+
message = "You have enabled lspconfig integration but plugins.lsp is not enabled.";
152+
}
153+
{
154+
when =
155+
builtins.isBool cfg.settings.integrations.coq
156+
&& !config.plugins.coq-nvim.enable
157+
&& cfg.settings.integrations.coq;
158+
message = "You have enabled coq integration but plugins.coq-nvim is not enabled.";
159+
}
160+
];
166161
};
167162
}

plugins/by-name/lsp-format/default.nix

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@ lib.nixvim.plugins.mkNeovimPlugin {
9090
};
9191

9292
extraConfig = cfg: {
93-
warnings = lib.mkIf (!config.plugins.lsp.enable) [
94-
"You have enabled `plugins.lsp-format` but have `plugins.lsp` disabled."
95-
];
93+
warnings = lib.nixvim.mkWarnings "plugins.lsp-format" {
94+
when = !config.plugins.lsp.enable;
95+
message = ''
96+
This plugin requires `plugins.lsp` to be enabled.
97+
'';
98+
};
9699

97100
plugins.lsp = {
98101
onAttach =

0 commit comments

Comments
 (0)