diff --git a/plugins/by-name/alpha/default.nix b/plugins/by-name/alpha/default.nix index c1ab131097..b665cd373d 100644 --- a/plugins/by-name/alpha/default.nix +++ b/plugins/by-name/alpha/default.nix @@ -153,11 +153,13 @@ in lib.mkIf cfg.enable { # 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. - '' - ]; + ''; + }; + plugins.web-devicons = lib.mkIf ( diff --git a/plugins/by-name/clangd-extensions/default.nix b/plugins/by-name/clangd-extensions/default.nix index abed68b46a..426e3437b9 100644 --- a/plugins/by-name/clangd-extensions/default.nix +++ b/plugins/by-name/clangd-extensions/default.nix @@ -122,10 +122,14 @@ lib.nixvim.plugins.mkNeovimPlugin { }; extraConfig = cfg: { - warnings = lib.optionals (!config.plugins.lsp.enable) '' - Nixvim (plugins.clangd-extensions): 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. - ''; + warnings = lib.nixvim.mkWarnings "plugins.clangd-extensions" { + when = !config.plugins.lsp.enable; + + 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 = { servers.clangd = { diff --git a/plugins/by-name/efmls-configs/default.nix b/plugins/by-name/efmls-configs/default.nix index 82b2e87524..3fbf0e534d 100644 --- a/plugins/by-name/efmls-configs/default.nix +++ b/plugins/by-name/efmls-configs/default.nix @@ -145,10 +145,14 @@ in extraPlugins = [ cfg.package ]; # TODO: print the location of the offending options - warnings = lib.optional (nixvimPkgs.wrong != [ ]) '' - Nixvim (plugins.efmls-configs): Following tools are not handled by nixvim, please add them to `externallyManagedPackages` to silence this: - ${lib.concatMapStringsSep "\n" (tool: " - ${tool}") nixvimPkgs.wrong} - ''; + warnings = lib.nixvim.mkWarnings "plugins.efmls-configs" { + when = 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 = { enable = true; diff --git a/plugins/by-name/firenvim/default.nix b/plugins/by-name/firenvim/default.nix index 90cf3784fd..ae40a40686 100644 --- a/plugins/by-name/firenvim/default.nix +++ b/plugins/by-name/firenvim/default.nix @@ -73,16 +73,16 @@ lib.nixvim.plugins.mkNeovimPlugin { callSetup = false; extraConfig = cfg: opts: { - warnings = - lib.optional - ( - config.performance.combinePlugins.enable - && !(lib.elem "firenvim" config.performance.combinePlugins.standalonePlugins) - ) - '' - Nixvim (plugins.firenvim): Using `performance.combinePlugins` breaks `firenvim`. - Add this plugin to `performance.combinePlugins.standalonePlugins` to prevent any issue. - ''; + warnings = lib.nixvim.mkWarnings "plugins.firenvim" { + when = + config.performance.combinePlugins.enable + && !(lib.elem "firenvim" config.performance.combinePlugins.standalonePlugins); + message = '' + 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; }; } diff --git a/plugins/by-name/flutter-tools/default.nix b/plugins/by-name/flutter-tools/default.nix index def7d48aa8..3fa4a90b2c 100644 --- a/plugins/by-name/flutter-tools/default.nix +++ b/plugins/by-name/flutter-tools/default.nix @@ -19,17 +19,17 @@ lib.nixvim.plugins.mkNeovimPlugin { extraConfig = cfg: { extraPackages = [ cfg.flutterPackage ]; - warnings = - lib.optional - ( - (cfg.settings ? debugger.enable) - && (lib.isBool cfg.settings.debugger.enable) - && cfg.settings.debugger.enable - && (!config.plugins.dap.enable) - ) - '' - Nixvim (plugins.flutter-tools): You have enabled the dap integration (`settings.debugger.enable`) but `plugins.dap` is disabled. - ''; + warnings = lib.nixvim.mkWarnings "plugins.flutter-tools" { + when = + (cfg.settings ? debugger.enable) + && (lib.isBool cfg.settings.debugger.enable) + && cfg.settings.debugger.enable + && (!config.plugins.dap.enable); + + message = '' + You have enabled the dap integration (`settings.debugger.enable`) but `plugins.dap` is disabled. + ''; + }; }; settingsOptions = import ./settings-options.nix lib; diff --git a/plugins/by-name/gitsigns/default.nix b/plugins/by-name/gitsigns/default.nix index 527c8f1cf3..ce05971fc7 100644 --- a/plugins/by-name/gitsigns/default.nix +++ b/plugins/by-name/gitsigns/default.nix @@ -101,13 +101,15 @@ lib.nixvim.plugins.mkNeovimPlugin { }; extraConfig = cfg: { - warnings = - optional ((isBool cfg.settings.trouble && cfg.settings.trouble) && !config.plugins.trouble.enable) - '' - Nixvim (plugins.gitsigns): You have enabled `plugins.gitsigns.settings.trouble` but - `plugins.trouble.enable` is `false`. - You should maybe enable the `trouble` plugin. - ''; + warnings = lib.nixvim.mkWarnings "plugins.gitsigns" { + when = (isBool cfg.settings.trouble && cfg.settings.trouble) && !config.plugins.trouble.enable; + + message = '' + You have enabled `plugins.gitsigns.settings.trouble` but `plugins.trouble.enable` is `false`. + You should maybe enable the `trouble` plugin. + ''; + }; + extraPackages = [ cfg.gitPackage ]; }; } diff --git a/plugins/by-name/glance/default.nix b/plugins/by-name/glance/default.nix index ddb1ef4296..22a0bbf216 100644 --- a/plugins/by-name/glance/default.nix +++ b/plugins/by-name/glance/default.nix @@ -16,14 +16,16 @@ lib.nixvim.plugins.mkNeovimPlugin { }; extraConfig = cfg: { - warnings = - lib.optional - ( - cfg.settings ? use_trouble_qf - && builtins.isBool cfg.settings.use_trouble_qf - && cfg.settings.use_trouble_qf - && !config.plugins.trouble.enable - ) - "Nixvim (plugins.glance): The `trouble` plugin is not enabled, so the `glance` plugin's `use_trouble_qf` setting has no effect."; + warnings = lib.nixvim.mkWarnings "plugins.glance" { + when = + cfg.settings ? use_trouble_qf + && builtins.isBool cfg.settings.use_trouble_qf + && cfg.settings.use_trouble_qf + && !config.plugins.trouble.enable; + + message = '' + The `trouble` plugin is not enabled, so the `glance` plugin's `use_trouble_qf` setting has no effect. + ''; + }; }; } diff --git a/plugins/by-name/headlines/default.nix b/plugins/by-name/headlines/default.nix index 7896e1be1b..a7330395b3 100644 --- a/plugins/by-name/headlines/default.nix +++ b/plugins/by-name/headlines/default.nix @@ -22,8 +22,12 @@ lib.nixvim.plugins.mkNeovimPlugin { }; extraConfig = { - warnings = optional (!config.plugins.treesitter.enable) '' - Nixvim (plugins.headlines): headlines requires `plugins.treesitter` to be enabled with the relevant grammars installed. - ''; + warnings = lib.nixvim.mkWarnings "plugins.headlines" { + when = !config.plugins.treesitter.enable; + + message = '' + headlines requires `plugins.treesitter` to be enabled with the relevant grammars installed. + ''; + }; }; } diff --git a/plugins/by-name/lir/default.nix b/plugins/by-name/lir/default.nix index 7fa22158f6..6c345f228c 100644 --- a/plugins/by-name/lir/default.nix +++ b/plugins/by-name/lir/default.nix @@ -19,17 +19,17 @@ lib.nixvim.plugins.mkNeovimPlugin { }; extraConfig = cfg: { - warnings = - lib.optional - ( - (cfg.settings ? devicons.enable) - && (lib.isBool cfg.settings.devicons.enable) - && cfg.settings.devicons.enable - && (!config.plugins.web-devicons.enable) - ) - '' - Nixvim (plugins.lir): You have enabled `settings.devicons.enable` but `plugins.web-devicons.enable` is `false`. - Consider enabling the plugin for proper devicons support. - ''; + warnings = lib.nixvim.mkWarnings "plugins.lir" { + when = + (cfg.settings ? devicons.enable) + && (lib.isBool cfg.settings.devicons.enable) + && cfg.settings.devicons.enable + && (!config.plugins.web-devicons.enable); + + message = '' + You have enabled `settings.devicons.enable` but `plugins.web-devicons.enable` is `false`. + Consider enabling the plugin for proper devicons support. + ''; + }; }; } diff --git a/plugins/by-name/molten/default.nix b/plugins/by-name/molten/default.nix index 6a3dadc97c..aa482e143e 100644 --- a/plugins/by-name/molten/default.nix +++ b/plugins/by-name/molten/default.nix @@ -241,10 +241,12 @@ mkVimPlugin { extraConfig = cfg: { extraPython3Packages = cfg.python3Dependencies; - warnings = - lib.optional (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. - ''; + warnings = lib.nixvim.mkWarnings "plugins.molten" { + when = cfg.settings.image_provider == "wezterm" && !config.plugins.wezterm.enable; + + message = '' + The `wezterm` plugin is not enabled, so the `molten` plugin's `image_provider` setting will have no effect. + ''; + }; }; } diff --git a/plugins/by-name/neoclip/default.nix b/plugins/by-name/neoclip/default.nix index 42e593be49..76dc38c44b 100644 --- a/plugins/by-name/neoclip/default.nix +++ b/plugins/by-name/neoclip/default.nix @@ -238,17 +238,16 @@ lib.nixvim.plugins.mkNeovimPlugin { extraConfig = cfg: { # TODO: added 2024-09-14 remove after 24.11 plugins.sqlite-lua.enable = mkOverride 1490 true; - warnings = - optional - ( - isBool cfg.settings.enable_persistent_history - && cfg.settings.enable_persistent_history - && options.plugins.sqlite-lua.enable.highestPrio == 1490 - ) - '' - Nixvim (plugins.neoclip) `sqlite-lua` automatic installation is deprecated. - Please use `plugins.sqlite-lua.enable`. - ''; + warnings = lib.nixvim.mkWarnings "plugins.neoclip" { + when = + isBool cfg.settings.enable_persistent_history + && cfg.settings.enable_persistent_history + && options.plugins.sqlite-lua.enable.highestPrio == 1490; + + message = '' + `sqlite-lua` automatic installation is deprecated. Please use `plugins.sqlite-lua.enable`. + ''; + }; assertions = [ { diff --git a/plugins/by-name/neotest/adapters.nix b/plugins/by-name/neotest/adapters.nix index dc7962b1a1..670a327971 100644 --- a/plugins/by-name/neotest/adapters.nix +++ b/plugins/by-name/neotest/adapters.nix @@ -44,10 +44,14 @@ let } ]; - warnings = optional (!config.plugins.treesitter.enable) '' - Nixvim (plugins.neotest.adapters.${name}): 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. - ''; + warnings = lib.nixvim.mkWarnings "plugins.neotest.adapters.${name}" { + when = !config.plugins.treesitter.enable; + + 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 = let diff --git a/plugins/by-name/notebook-navigator/default.nix b/plugins/by-name/notebook-navigator/default.nix index 597630cdc8..f8f4aa4d03 100644 --- a/plugins/by-name/notebook-navigator/default.nix +++ b/plugins/by-name/notebook-navigator/default.nix @@ -103,20 +103,25 @@ lib.nixvim.plugins.mkNeovimPlugin { }; extraConfig = cfg: { - warnings = - (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` - 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" - 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`. - ''; + warnings = lib.nixvim.mkWarnings "plugins.notebook-navigator" [ + { + when = (cfg.settings.activate_hydra_keys != null) && (!config.plugins.hydra.enable); + message = '' + `settings.activate_hydra_keys` has been set to a non-`null` value but `plugins.hydra.enable` is `false`. + ''; + } + { + when = (cfg.settings.repl_provider == "toggleterm") && (!config.plugins.toggleterm.enable); + message = '' + `settings.repl_provider` has been set to "toggleterm" but `plugins.hydra.toggleterm.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`. + ''; + } + ]; }; } diff --git a/plugins/by-name/rest/default.nix b/plugins/by-name/rest/default.nix index 6a847d45a0..c81ea4581d 100644 --- a/plugins/by-name/rest/default.nix +++ b/plugins/by-name/rest/default.nix @@ -287,10 +287,13 @@ lib.nixvim.plugins.mkNeovimPlugin { ] ]; in - lib.optional (definedOpts != [ ]) '' - Nixvim(plugins.rest): The following v2 settings options are no longer supported in v3: - ${lib.concatMapStringsSep "\n" (opt: " - ${lib.showOption (lib.toList opt)}") definedOpts} - ''; + lib.nixvim.mkWarnings "plugins.rest" { + when = 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 plugins.rest.luaConfig.post = lib.mkIf cfg.enableTelescope ''require("telescope").load_extension("rest")''; diff --git a/plugins/by-name/vim-matchup/default.nix b/plugins/by-name/vim-matchup/default.nix index 7f9f255fd1..e6ab055ac3 100644 --- a/plugins/by-name/vim-matchup/default.nix +++ b/plugins/by-name/vim-matchup/default.nix @@ -84,11 +84,14 @@ lib.nixvim.plugins.mkVimPlugin { }; extraConfig = cfg: { - warnings = lib.optional (cfg.treesitter.enable && (!config.plugins.treesitter.enable)) '' - Nixvim (plugins.vim-matchup): `plugins.vim-matchup.treesitter.enable` is `true`, but the - treesitter plugin itself is not. - -> Set `plugins.treesitter.enable` to `true`. - ''; + warnings = lib.nixvim.mkWarnings "plugins.vim-matchup" { + when = cfg.treesitter.enable && (!config.plugins.treesitter.enable); + + 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; }; diff --git a/plugins/by-name/yanky/default.nix b/plugins/by-name/yanky/default.nix index 02243a13ed..4397fa0910 100644 --- a/plugins/by-name/yanky/default.nix +++ b/plugins/by-name/yanky/default.nix @@ -349,13 +349,15 @@ lib.nixvim.plugins.mkNeovimPlugin { extraConfig = cfg: { # TODO: Added 2024-09-14 remove after 24.11 plugins.sqlite-lua.enable = mkOverride 1490 true; - warnings = - optional - (cfg.settings.ring.storage == "sqlite" && options.plugins.sqlite-lua.enable.highestPrio == 1490) - '' - Nixvim (plugins.yanky) `sqlite-lua` automatic installation is deprecated. - Please use `plugins.sqlite-lua.enable`. - ''; + warnings = lib.nixvim.mkWarnings "plugins.yanky" { + when = + cfg.settings.ring.storage == "sqlite" && options.plugins.sqlite-lua.enable.highestPrio == 1490; + + message = '' + `sqlite-lua` automatic installation is deprecated. + Please use `plugins.sqlite-lua.enable`. + ''; + }; assertions = [ { diff --git a/plugins/by-name/zk/default.nix b/plugins/by-name/zk/default.nix index dfc509f18f..b8dcb34cba 100644 --- a/plugins/by-name/zk/default.nix +++ b/plugins/by-name/zk/default.nix @@ -115,14 +115,14 @@ lib.nixvim.plugins.mkNeovimPlugin { extraConfig = cfg: { extraPackages = [ cfg.zkPackage ]; - warnings = flatten ( + warnings = lib.nixvim.mkWarnings "plugins.zk" ( mapAttrsToList - ( - picker: pluginName: - optional ((cfg.settings.picker == picker) && !config.plugins.${pluginName}.enable) '' - Nixvim (plugins.zk): You have set `plugins.zk.settings.picker = "${picker}"` but `plugins.${pluginName}` is not enabled in your config. - '' - ) + (picker: pluginName: { + when = (cfg.settings.picker == picker) && !config.plugins.${pluginName}.enable; + message = '' + You have set `plugins.zk.settings.picker = "${picker}"` but `plugins.${pluginName}` is not enabled in your config. + ''; + }) { fzf_lua = "fzf-lua"; telescope = "telescope";