treewide: use mkWarnings wherever possible

This commit is contained in:
Gaetan Lepage 2025-01-17 16:18:38 +01:00
parent 2ec6218f87
commit 60adb6c56b
17 changed files with 158 additions and 122 deletions

View file

@ -153,11 +153,13 @@ in
lib.mkIf cfg.enable { lib.mkIf cfg.enable {
# TODO: added 2024-09-20 remove after 24.11 # TODO: added 2024-09-20 remove after 24.11
warnings = lib.optionals opt.iconsEnabled.isDefined [ warnings = lib.nixvim.mkWarnings "plugins.alpha" {
'' when = opt.iconsEnabled.isDefined;
message = ''
The option definition `plugins.alpha.iconsEnabled' in ${lib.showFiles opt.iconsEnabled.files} has been deprecated; please remove it. The option definition `plugins.alpha.iconsEnabled' in ${lib.showFiles opt.iconsEnabled.files} has been deprecated; please remove it.
'' '';
]; };
plugins.web-devicons = plugins.web-devicons =
lib.mkIf lib.mkIf
( (

View file

@ -122,10 +122,14 @@ lib.nixvim.plugins.mkNeovimPlugin {
}; };
extraConfig = cfg: { extraConfig = cfg: {
warnings = lib.optionals (!config.plugins.lsp.enable) '' warnings = lib.nixvim.mkWarnings "plugins.clangd-extensions" {
Nixvim (plugins.clangd-extensions): You have enabled `clangd-extensions` but not the lsp (`plugins.lsp`). when = !config.plugins.lsp.enable;
You should set `plugins.lsp.enable = true` to make use of the clangd-extensions' features.
''; message = ''
You have enabled `clangd-extensions` but not the lsp (`plugins.lsp`).
You should set `plugins.lsp.enable = true` to make use of the clangd-extensions' features.
'';
};
plugins.lsp = { plugins.lsp = {
servers.clangd = { servers.clangd = {

View file

@ -145,10 +145,14 @@ in
extraPlugins = [ cfg.package ]; extraPlugins = [ cfg.package ];
# TODO: print the location of the offending options # TODO: print the location of the offending options
warnings = lib.optional (nixvimPkgs.wrong != [ ]) '' warnings = lib.nixvim.mkWarnings "plugins.efmls-configs" {
Nixvim (plugins.efmls-configs): Following tools are not handled by nixvim, please add them to `externallyManagedPackages` to silence this: when = nixvimPkgs.wrong != [ ];
${lib.concatMapStringsSep "\n" (tool: " - ${tool}") nixvimPkgs.wrong}
''; message = ''
Following tools are not handled by nixvim, please add them to `externallyManagedPackages` to silence this:
${lib.concatMapStringsSep "\n" (tool: " - ${tool}") nixvimPkgs.wrong}
'';
};
plugins.lsp.servers.efm = { plugins.lsp.servers.efm = {
enable = true; enable = true;

View file

@ -73,16 +73,16 @@ lib.nixvim.plugins.mkNeovimPlugin {
callSetup = false; callSetup = false;
extraConfig = cfg: opts: { extraConfig = cfg: opts: {
warnings = warnings = lib.nixvim.mkWarnings "plugins.firenvim" {
lib.optional when =
( config.performance.combinePlugins.enable
config.performance.combinePlugins.enable && !(lib.elem "firenvim" config.performance.combinePlugins.standalonePlugins);
&& !(lib.elem "firenvim" config.performance.combinePlugins.standalonePlugins) message = ''
) Using `performance.combinePlugins` breaks `firenvim`.
'' Add this plugin to `performance.combinePlugins.standalonePlugins` to prevent any issue.
Nixvim (plugins.firenvim): Using `performance.combinePlugins` breaks `firenvim`. '';
Add this plugin to `performance.combinePlugins.standalonePlugins` to prevent any issue. };
'';
globals.firenvim_config = lib.modules.mkAliasAndWrapDefsWithPriority lib.id opts.settings; globals.firenvim_config = lib.modules.mkAliasAndWrapDefsWithPriority lib.id opts.settings;
}; };
} }

View file

@ -19,17 +19,17 @@ lib.nixvim.plugins.mkNeovimPlugin {
extraConfig = cfg: { extraConfig = cfg: {
extraPackages = [ cfg.flutterPackage ]; extraPackages = [ cfg.flutterPackage ];
warnings = warnings = lib.nixvim.mkWarnings "plugins.flutter-tools" {
lib.optional when =
( (cfg.settings ? debugger.enable)
(cfg.settings ? debugger.enable) && (lib.isBool cfg.settings.debugger.enable)
&& (lib.isBool cfg.settings.debugger.enable) && cfg.settings.debugger.enable
&& cfg.settings.debugger.enable && (!config.plugins.dap.enable);
&& (!config.plugins.dap.enable)
) message = ''
'' You have enabled the dap integration (`settings.debugger.enable`) but `plugins.dap` is disabled.
Nixvim (plugins.flutter-tools): You have enabled the dap integration (`settings.debugger.enable`) but `plugins.dap` is disabled. '';
''; };
}; };
settingsOptions = import ./settings-options.nix lib; settingsOptions = import ./settings-options.nix lib;

View file

@ -101,13 +101,15 @@ lib.nixvim.plugins.mkNeovimPlugin {
}; };
extraConfig = cfg: { extraConfig = cfg: {
warnings = warnings = lib.nixvim.mkWarnings "plugins.gitsigns" {
optional ((isBool cfg.settings.trouble && cfg.settings.trouble) && !config.plugins.trouble.enable) when = (isBool cfg.settings.trouble && cfg.settings.trouble) && !config.plugins.trouble.enable;
''
Nixvim (plugins.gitsigns): You have enabled `plugins.gitsigns.settings.trouble` but message = ''
`plugins.trouble.enable` is `false`. You have enabled `plugins.gitsigns.settings.trouble` but `plugins.trouble.enable` is `false`.
You should maybe enable the `trouble` plugin. You should maybe enable the `trouble` plugin.
''; '';
};
extraPackages = [ cfg.gitPackage ]; extraPackages = [ cfg.gitPackage ];
}; };
} }

View file

@ -16,14 +16,16 @@ lib.nixvim.plugins.mkNeovimPlugin {
}; };
extraConfig = cfg: { extraConfig = cfg: {
warnings = warnings = lib.nixvim.mkWarnings "plugins.glance" {
lib.optional when =
( cfg.settings ? use_trouble_qf
cfg.settings ? use_trouble_qf && builtins.isBool cfg.settings.use_trouble_qf
&& builtins.isBool cfg.settings.use_trouble_qf && cfg.settings.use_trouble_qf
&& cfg.settings.use_trouble_qf && !config.plugins.trouble.enable;
&& !config.plugins.trouble.enable
) message = ''
"Nixvim (plugins.glance): The `trouble` plugin is not enabled, so the `glance` plugin's `use_trouble_qf` setting has no effect."; The `trouble` plugin is not enabled, so the `glance` plugin's `use_trouble_qf` setting has no effect.
'';
};
}; };
} }

View file

@ -22,8 +22,12 @@ lib.nixvim.plugins.mkNeovimPlugin {
}; };
extraConfig = { extraConfig = {
warnings = optional (!config.plugins.treesitter.enable) '' warnings = lib.nixvim.mkWarnings "plugins.headlines" {
Nixvim (plugins.headlines): headlines requires `plugins.treesitter` to be enabled with the relevant grammars installed. when = !config.plugins.treesitter.enable;
'';
message = ''
headlines requires `plugins.treesitter` to be enabled with the relevant grammars installed.
'';
};
}; };
} }

View file

@ -19,17 +19,17 @@ lib.nixvim.plugins.mkNeovimPlugin {
}; };
extraConfig = cfg: { extraConfig = cfg: {
warnings = warnings = lib.nixvim.mkWarnings "plugins.lir" {
lib.optional when =
( (cfg.settings ? devicons.enable)
(cfg.settings ? devicons.enable) && (lib.isBool cfg.settings.devicons.enable)
&& (lib.isBool cfg.settings.devicons.enable) && cfg.settings.devicons.enable
&& cfg.settings.devicons.enable && (!config.plugins.web-devicons.enable);
&& (!config.plugins.web-devicons.enable)
) message = ''
'' You have enabled `settings.devicons.enable` but `plugins.web-devicons.enable` is `false`.
Nixvim (plugins.lir): You have enabled `settings.devicons.enable` but `plugins.web-devicons.enable` is `false`. Consider enabling the plugin for proper devicons support.
Consider enabling the plugin for proper devicons support. '';
''; };
}; };
} }

View file

@ -241,10 +241,12 @@ mkVimPlugin {
extraConfig = cfg: { extraConfig = cfg: {
extraPython3Packages = cfg.python3Dependencies; extraPython3Packages = cfg.python3Dependencies;
warnings = warnings = lib.nixvim.mkWarnings "plugins.molten" {
lib.optional (cfg.settings.image_provider == "wezterm" && !config.plugins.wezterm.enable) when = cfg.settings.image_provider == "wezterm" && !config.plugins.wezterm.enable;
''
Nixvim (plugins.molten): The `wezterm` plugin is not enabled, so the `molten` plugin's `image_provider` setting will have no effect. message = ''
''; The `wezterm` plugin is not enabled, so the `molten` plugin's `image_provider` setting will have no effect.
'';
};
}; };
} }

View file

@ -238,17 +238,16 @@ lib.nixvim.plugins.mkNeovimPlugin {
extraConfig = cfg: { extraConfig = cfg: {
# TODO: added 2024-09-14 remove after 24.11 # TODO: added 2024-09-14 remove after 24.11
plugins.sqlite-lua.enable = mkOverride 1490 true; plugins.sqlite-lua.enable = mkOverride 1490 true;
warnings = warnings = lib.nixvim.mkWarnings "plugins.neoclip" {
optional when =
( isBool cfg.settings.enable_persistent_history
isBool cfg.settings.enable_persistent_history && cfg.settings.enable_persistent_history
&& cfg.settings.enable_persistent_history && options.plugins.sqlite-lua.enable.highestPrio == 1490;
&& options.plugins.sqlite-lua.enable.highestPrio == 1490
) message = ''
'' `sqlite-lua` automatic installation is deprecated. Please use `plugins.sqlite-lua.enable`.
Nixvim (plugins.neoclip) `sqlite-lua` automatic installation is deprecated. '';
Please use `plugins.sqlite-lua.enable`. };
'';
assertions = [ assertions = [
{ {

View file

@ -44,10 +44,14 @@ let
} }
]; ];
warnings = optional (!config.plugins.treesitter.enable) '' warnings = lib.nixvim.mkWarnings "plugins.neotest.adapters.${name}" {
Nixvim (plugins.neotest.adapters.${name}): This adapter requires `treesitter` to be enabled. when = !config.plugins.treesitter.enable;
You might want to set `plugins.treesitter.enable = true` and ensure that the `${treesitter-parser}` parser is enabled.
''; message = ''
This adapter requires `treesitter` to be enabled.
You might want to set `plugins.treesitter.enable = true` and ensure that the `${treesitter-parser}` parser is enabled.
'';
};
plugins.neotest.settings.adapters = plugins.neotest.settings.adapters =
let let

View file

@ -103,20 +103,25 @@ lib.nixvim.plugins.mkNeovimPlugin {
}; };
extraConfig = cfg: { extraConfig = cfg: {
warnings = warnings = lib.nixvim.mkWarnings "plugins.notebook-navigator" [
(lib.optional ((cfg.settings.activate_hydra_keys != null) && (!config.plugins.hydra.enable)) '' {
Nixvim (plugins.notebook-navigator): `plugins.notebook-navigator.settings.activate_hydra_keys` has been set to a non-`null` when = (cfg.settings.activate_hydra_keys != null) && (!config.plugins.hydra.enable);
value but `plugins.hydra.enable` is `false`. message = ''
'') `settings.activate_hydra_keys` has been set to a non-`null` value but `plugins.hydra.enable` is `false`.
++ '';
(lib.optional ((cfg.settings.repl_provider == "toggleterm") && (!config.plugins.toggleterm.enable))) }
'' {
Nixvim (plugins.notebook-navigator): `plugins.notebook-navigator.settings.repl_provider` has been set to "toggleterm" when = (cfg.settings.repl_provider == "toggleterm") && (!config.plugins.toggleterm.enable);
but `plugins.hydra.toggleterm.enable` is `false`. message = ''
'' `settings.repl_provider` has been set to "toggleterm" but `plugins.hydra.toggleterm.enable` is `false`.
++ (lib.optional ((cfg.settings.repl_provider == "molten") && (!config.plugins.molten.enable))) '' '';
Nixvim (plugins.notebook-navigator): `plugins.notebook-navigator.settings.repl_provider` has been set to "molten" }
but `plugins.molten.enable` is `false`. {
''; when = (cfg.settings.repl_provider == "molten") && (!config.plugins.molten.enable);
message = ''
`settings.repl_provider` has been set to "molten" but `plugins.molten.enable` is `false`.
'';
}
];
}; };
} }

View file

@ -287,10 +287,13 @@ lib.nixvim.plugins.mkNeovimPlugin {
] ]
]; ];
in in
lib.optional (definedOpts != [ ]) '' lib.nixvim.mkWarnings "plugins.rest" {
Nixvim(plugins.rest): The following v2 settings options are no longer supported in v3: when = definedOpts != [ ];
${lib.concatMapStringsSep "\n" (opt: " - ${lib.showOption (lib.toList opt)}") definedOpts} message = ''
''; The following v2 settings options are no longer supported in v3:
${lib.concatMapStringsSep "\n" (opt: " - ${lib.showOption (lib.toList opt)}") definedOpts}
'';
};
# TODO: There may be some interactions between this & telescope, maybe requiring #2292 # TODO: There may be some interactions between this & telescope, maybe requiring #2292
plugins.rest.luaConfig.post = lib.mkIf cfg.enableTelescope ''require("telescope").load_extension("rest")''; plugins.rest.luaConfig.post = lib.mkIf cfg.enableTelescope ''require("telescope").load_extension("rest")'';

View file

@ -84,11 +84,14 @@ lib.nixvim.plugins.mkVimPlugin {
}; };
extraConfig = cfg: { extraConfig = cfg: {
warnings = lib.optional (cfg.treesitter.enable && (!config.plugins.treesitter.enable)) '' warnings = lib.nixvim.mkWarnings "plugins.vim-matchup" {
Nixvim (plugins.vim-matchup): `plugins.vim-matchup.treesitter.enable` is `true`, but the when = cfg.treesitter.enable && (!config.plugins.treesitter.enable);
treesitter plugin itself is not.
-> Set `plugins.treesitter.enable` to `true`. message = ''
''; `plugins.vim-matchup.treesitter.enable` is `true`, but the treesitter plugin itself is not.
-> Set `plugins.treesitter.enable` to `true`.
'';
};
plugins.treesitter.settings.matchup = cfg.treesitter; plugins.treesitter.settings.matchup = cfg.treesitter;
}; };

View file

@ -349,13 +349,15 @@ lib.nixvim.plugins.mkNeovimPlugin {
extraConfig = cfg: { extraConfig = cfg: {
# TODO: Added 2024-09-14 remove after 24.11 # TODO: Added 2024-09-14 remove after 24.11
plugins.sqlite-lua.enable = mkOverride 1490 true; plugins.sqlite-lua.enable = mkOverride 1490 true;
warnings = warnings = lib.nixvim.mkWarnings "plugins.yanky" {
optional when =
(cfg.settings.ring.storage == "sqlite" && options.plugins.sqlite-lua.enable.highestPrio == 1490) cfg.settings.ring.storage == "sqlite" && options.plugins.sqlite-lua.enable.highestPrio == 1490;
''
Nixvim (plugins.yanky) `sqlite-lua` automatic installation is deprecated. message = ''
Please use `plugins.sqlite-lua.enable`. `sqlite-lua` automatic installation is deprecated.
''; Please use `plugins.sqlite-lua.enable`.
'';
};
assertions = [ assertions = [
{ {

View file

@ -115,14 +115,14 @@ lib.nixvim.plugins.mkNeovimPlugin {
extraConfig = cfg: { extraConfig = cfg: {
extraPackages = [ cfg.zkPackage ]; extraPackages = [ cfg.zkPackage ];
warnings = flatten ( warnings = lib.nixvim.mkWarnings "plugins.zk" (
mapAttrsToList mapAttrsToList
( (picker: pluginName: {
picker: pluginName: when = (cfg.settings.picker == picker) && !config.plugins.${pluginName}.enable;
optional ((cfg.settings.picker == picker) && !config.plugins.${pluginName}.enable) '' message = ''
Nixvim (plugins.zk): You have set `plugins.zk.settings.picker = "${picker}"` but `plugins.${pluginName}` is not enabled in your config. You have set `plugins.zk.settings.picker = "${picker}"` but `plugins.${pluginName}` is not enabled in your config.
'' '';
) })
{ {
fzf_lua = "fzf-lua"; fzf_lua = "fzf-lua";
telescope = "telescope"; telescope = "telescope";