diff --git a/modules/lazyload.nix b/modules/lazyload.nix index 832d425796..2c5123c2e6 100644 --- a/modules/lazyload.nix +++ b/modules/lazyload.nix @@ -45,14 +45,16 @@ in ) (builtins.attrNames config.plugins); count = builtins.length pluginsWithLazyLoad; in - lib.optionals (count > 0 && !config.plugins.lz-n.enable) [ - '' + lib.nixvim.mkWarnings "lazy loading" { + when = count > 0 && !config.plugins.lz-n.enable; + + message = '' You have enabled lazy loading support for the following plugins but have not enabled a lazy loading provider. ${lib.concatImapStringsSep "\n" (i: x: "${toString i}. plugins.${x}") pluginsWithLazyLoad} Currently supported lazy providers: - lz-n - '' - ]; + ''; + }; }; } diff --git a/plugins/by-name/auto-save/default.nix b/plugins/by-name/auto-save/default.nix index 51dc03bef4..d55292ecdd 100644 --- a/plugins/by-name/auto-save/default.nix +++ b/plugins/by-name/auto-save/default.nix @@ -166,10 +166,13 @@ lib.nixvim.plugins.mkNeovimPlugin { ] ]; in - lib.optional (definedOpts != [ ]) '' - Nixvim(plugins.auto-save): The following settings options are no longer supported. - Check the plugin documentation for more details.: - ${lib.concatMapStringsSep "\n" (opt: " - ${lib.showOption (lib.toList opt)}") definedOpts} - ''; + lib.nixvim.mkWarnings "plugins.auto-save" { + when = definedOpts != [ ]; + message = '' + The following settings options are no longer supported. + Check the plugin documentation for more details.: + ${lib.concatMapStringsSep "\n" (opt: " - ${lib.showOption (lib.toList opt)}") definedOpts} + ''; + }; }; } diff --git a/plugins/by-name/blink-cmp-copilot/default.nix b/plugins/by-name/blink-cmp-copilot/default.nix index 6c71c3551b..4b8160847e 100644 --- a/plugins/by-name/blink-cmp-copilot/default.nix +++ b/plugins/by-name/blink-cmp-copilot/default.nix @@ -50,18 +50,23 @@ lib.nixvim.plugins.mkNeovimPlugin { copilot-lua-cfg = config.plugins.copilot-lua.settings; isEnabled = b: builtins.isBool b && b; in - lib.optionals (isEnabled copilot-lua-cfg.suggestion.enabled) [ - '' - It is recommended to disable copilot's `suggestion` module, as it can interfere with - completions properly appearing in blink-cmp-copilot. - '' - ] - ++ lib.optionals (isEnabled copilot-lua-cfg.panel.enabled) [ - '' - It is recommended to disable copilot's `panel` module, as it can interfere with completions - properly appearing in blink-cmp-copilot. - '' + lib.nixvim.mkWarnings "plugins.blink-cmp-copilot" [ + { + when = isEnabled copilot-lua-cfg.suggestion.enabled; + message = '' + It is recommended to disable copilot's `suggestion` module, as it can interfere with + completions properly appearing in blink-cmp-copilot. + ''; + } + { + when = isEnabled copilot-lua-cfg.panel.enabled; + message = '' + It is recommended to disable copilot's `panel` module, as it can interfere with completions + properly appearing in blink-cmp-copilot. + ''; + } ]; + plugins.copilot-lua.enable = lib.mkDefault true; }; } diff --git a/plugins/by-name/blink-cmp/default.nix b/plugins/by-name/blink-cmp/default.nix index 8dab77827f..fa7fc9f94d 100644 --- a/plugins/by-name/blink-cmp/default.nix +++ b/plugins/by-name/blink-cmp/default.nix @@ -44,8 +44,11 @@ lib.nixvim.plugins.mkNeovimPlugin { }; extraConfig = cfg: { - warnings = lib.optional (cfg.settings ? documentation) '' - Nixvim(plugins.blink): `settings.documentation` does not correspond to a known setting, use `settings.windows.documentation` instead. - ''; + warnings = lib.nixvim.mkWarnings "plugins.blink" { + when = cfg.settings ? documentation; + message = '' + `settings.documentation` does not correspond to a known setting, use `settings.windows.documentation` instead. + ''; + }; }; } diff --git a/plugins/by-name/copilot-cmp/default.nix b/plugins/by-name/copilot-cmp/default.nix index b654f875c8..ecbf364611 100644 --- a/plugins/by-name/copilot-cmp/default.nix +++ b/plugins/by-name/copilot-cmp/default.nix @@ -60,14 +60,22 @@ lib.nixvim.plugins.mkNeovimPlugin { copilot-lua-cfg = config.plugins.copilot-lua.settings; isEnabled = b: (lib.isBool b && b); in - lib.optional (isEnabled copilot-lua-cfg.suggestion.enabled) '' - It is recommended to disable copilot's `suggestion` module, as it can interfere with - completions properly appearing in copilot-cmp. - '' - ++ lib.optional (isEnabled copilot-lua-cfg.panel.enabled) '' - It is recommended to disable copilot's `panel` module, as it can interfere with completions - properly appearing in copilot-cmp. - ''; + lib.nixvim.mkWarnings "plugins.copilot-cmp" [ + { + when = isEnabled copilot-lua-cfg.suggestion.enabled; + message = '' + It is recommended to disable copilot's `suggestion` module, as it can interfere with + completions properly appearing in copilot-cmp. + ''; + } + { + when = isEnabled copilot-lua-cfg.panel.enabled; + message = '' + It is recommended to disable copilot's `panel` module, as it can interfere with completions + properly appearing in copilot-cmp. + ''; + } + ]; plugins.copilot-lua.enable = lib.mkDefault true; }; diff --git a/plugins/by-name/fidget/default.nix b/plugins/by-name/fidget/default.nix index cab7c80679..eacd062849 100644 --- a/plugins/by-name/fidget/default.nix +++ b/plugins/by-name/fidget/default.nix @@ -470,16 +470,16 @@ lib.nixvim.plugins.mkNeovimPlugin { }; extraConfig = cfg: { - warnings = - lib.optionals - ( - (builtins.isBool cfg.settings.integration.nvim-tree.enable) - && cfg.settings.integration.nvim-tree.enable - && !config.plugins.nvim-tree.enable - ) - [ - "Nixvim(plugins.fidget): You have set `plugins.fidget.settings.integrations.nvim-tree.enable` to true but have not enabled `plugins.nvim-tree`." - ]; + warnings = lib.nixvim.mkWarnings "plugins.fidget" { + when = + (builtins.isBool cfg.settings.integration.nvim-tree.enable) + && cfg.settings.integration.nvim-tree.enable + && !config.plugins.nvim-tree.enable; + + message = '' + You have set `plugins.fidget.settings.integrations.nvim-tree.enable` to true but have not enabled `plugins.nvim-tree`. + ''; + }; }; inherit (import ./deprecations.nix { inherit lib; }) imports optionsRenamedToSettings; diff --git a/plugins/by-name/fzf-lua/default.nix b/plugins/by-name/fzf-lua/default.nix index df2cb85598..56cd6c9eaf 100644 --- a/plugins/by-name/fzf-lua/default.nix +++ b/plugins/by-name/fzf-lua/default.nix @@ -105,11 +105,14 @@ lib.nixvim.plugins.mkNeovimPlugin { extraConfig = cfg: opts: { # TODO: deprecated 2024-08-29 remove after 24.11 - warnings = lib.optionals opts.iconsEnabled.isDefined [ - '' + warnings = lib.nixvim.mkWarnings "plugins.fzf-lua" { + when = opts.iconsEnabled.isDefined; + + message = '' The option definition `plugins.fzf-lua.iconsEnabled' in ${lib.showFiles opts.iconsEnabled.files} has been deprecated; please remove it. - '' - ]; + ''; + }; + # TODO: added 2024-09-20 remove after 24.11 plugins.web-devicons = lib.mkIf diff --git a/plugins/by-name/hmts/default.nix b/plugins/by-name/hmts/default.nix index b8d4e199c2..793ca24f52 100644 --- a/plugins/by-name/hmts/default.nix +++ b/plugins/by-name/hmts/default.nix @@ -14,8 +14,9 @@ lib.nixvim.plugins.mkNeovimPlugin { hasSettings = false; hasLuaConfig = false; extraConfig = { - warnings = lib.optional ( - !config.plugins.treesitter.enable - ) "Nixvim: hmts needs treesitter to function as intended"; + warnings = lib.nixvim.mkWarnings "plugins.hmts" { + when = !config.plugins.treesitter.enable; + message = "hmts needs treesitter to function as intended"; + }; }; } diff --git a/plugins/by-name/lazydev/default.nix b/plugins/by-name/lazydev/default.nix index 74be90ae8d..6a9861e136 100644 --- a/plugins/by-name/lazydev/default.nix +++ b/plugins/by-name/lazydev/default.nix @@ -135,33 +135,28 @@ lib.nixvim.plugins.mkNeovimPlugin { }; extraConfig = cfg: { - warnings = - lib.optionals - ( + warnings = lib.nixvim.mkWarnings "plugins.lazydev" [ + { + when = builtins.isBool cfg.settings.integrations.cmp && !config.plugins.cmp.enable - && cfg.settings.integrations.cmp - ) - [ "Nixvim(plugins.lazydev): you have enabled nvim-cmp integration but plugins.cmp is not enabled." ] - ++ - lib.optionals - ( - builtins.isBool cfg.settings.integrations.lspconfig - && !config.plugins.lsp.enable - && cfg.settings.integrations.lspconfig - ) - [ - "Nixvim(plugins.lazydev): you have enabled lspconfig integration but plugins.lsp is not enabled." - ] - ++ - lib.optionals - ( - builtins.isBool cfg.settings.integrations.coq - && !config.plugins.coq-nvim.enable - && cfg.settings.integrations.coq - ) - [ - "Nixvim(plugins.lazydev): you have enabled coq integration but plugins.coq-nvim is not enabled." - ]; + && cfg.settings.integrations.cmp; + message = "You have enabled nvim-cmp integration but plugins.cmp is not enabled."; + } + { + when = + builtins.isBool cfg.settings.integrations.lspconfig + && !config.plugins.lsp.enable + && cfg.settings.integrations.lspconfig; + message = "You have enabled lspconfig integration but plugins.lsp is not enabled."; + } + { + when = + builtins.isBool cfg.settings.integrations.coq + && !config.plugins.coq-nvim.enable + && cfg.settings.integrations.coq; + message = "You have enabled coq integration but plugins.coq-nvim is not enabled."; + } + ]; }; } diff --git a/plugins/by-name/lsp-format/default.nix b/plugins/by-name/lsp-format/default.nix index f65b8ba9ac..fe7863d0b5 100644 --- a/plugins/by-name/lsp-format/default.nix +++ b/plugins/by-name/lsp-format/default.nix @@ -90,9 +90,12 @@ lib.nixvim.plugins.mkNeovimPlugin { }; extraConfig = cfg: { - warnings = lib.mkIf (!config.plugins.lsp.enable) [ - "You have enabled `plugins.lsp-format` but have `plugins.lsp` disabled." - ]; + warnings = lib.nixvim.mkWarnings "plugins.lsp-format" { + when = !config.plugins.lsp.enable; + message = '' + This plugin requires `plugins.lsp` to be enabled. + ''; + }; plugins.lsp = { onAttach = diff --git a/plugins/by-name/lspsaga/default.nix b/plugins/by-name/lspsaga/default.nix index 3e88acf69e..d7aa350be8 100644 --- a/plugins/by-name/lspsaga/default.nix +++ b/plugins/by-name/lspsaga/default.nix @@ -467,11 +467,16 @@ in { enable = mkOverride 1490 true; }; - warnings = lib.optional ( + warnings = lib.nixvim.mkWarnings "plugins.ltex-extra" { # https://nvimdev.github.io/lspsaga/implement/#default-options - (isBool cfg.implement.enable && cfg.implement.enable) - && (isBool cfg.symbolInWinbar.enable && !cfg.symbolInWinbar.enable) - ) "You have enabled the `implement` module but it requires `symbolInWinbar` to be enabled."; + when = + (isBool cfg.implement.enable && cfg.implement.enable) + && (isBool cfg.symbolInWinbar.enable && !cfg.symbolInWinbar.enable); + + message = '' + You have enabled the `implement` module but it requires `symbolInWinbar` to be enabled. + ''; + }; extraPlugins = [ cfg.package ]; extraConfigLua = diff --git a/plugins/by-name/ltex-extra/default.nix b/plugins/by-name/ltex-extra/default.nix index c505cf399d..d5e7f0a12c 100644 --- a/plugins/by-name/ltex-extra/default.nix +++ b/plugins/by-name/ltex-extra/default.nix @@ -44,10 +44,13 @@ lib.nixvim.plugins.mkNeovimPlugin { }; extraConfig = cfg: { - warnings = optional (!config.plugins.lsp.enable) '' - You have enabled `ltex-extra` but not the lsp (`plugins.lsp`). - You should set `plugins.lsp.enable = true` to make use of the LTeX_extra plugin's features. - ''; + warnings = lib.nixvim.mkWarnings "plugins.ltex-extra" { + when = !config.plugins.lsp.enable; + message = '' + You have enabled `ltex-extra` but not the lsp (`plugins.lsp`). + You should set `plugins.lsp.enable = true` to make use of the LTeX_extra plugin's features. + ''; + }; plugins.lsp = { servers.ltex = { diff --git a/plugins/by-name/neorg/default.nix b/plugins/by-name/neorg/default.nix index 25891562d6..e1c4ea1ac8 100644 --- a/plugins/by-name/neorg/default.nix +++ b/plugins/by-name/neorg/default.nix @@ -211,16 +211,27 @@ lib.nixvim.plugins.mkNeovimPlugin { modules = cfg.settings.load or { }; telescopeModuleEnabled = (modules."core.integrations.telescope" or null) != null; in - (lib.optional (telescopeModuleEnabled && (!cfg.telescopeIntegration.enable)) '' - You have enabled the telescope neorg module (`core.integrations.telescope`) but have not enabled `plugins.neorg.telescopeIntegration.enable`. - The latter will install the `neorg-telescope` plugin necessary for this integration to work. - '') - ++ (lib.optional (cfg.telescopeIntegration.enable && (!config.plugins.telescope.enable)) '' - Telescope support for neorg is enabled but the telescope plugin is not. - '') - ++ (lib.optional ((modules ? "core.defaults") && (!config.plugins.treesitter.enable)) '' - Neorg's `core.defaults` module is enabled but `plugins.treesitter` is not. - Treesitter is required when using the `core.defaults`. - ''); + lib.nixvim.mkWarnings "plugins.neorg" [ + { + when = telescopeModuleEnabled && (!cfg.telescopeIntegration.enable); + message = '' + You have enabled the telescope neorg module (`core.integrations.telescope`) but have not enabled `plugins.neorg.telescopeIntegration.enable`. + The latter will install the `neorg-telescope` plugin necessary for this integration to work. + ''; + } + { + when = cfg.telescopeIntegration.enable && (!config.plugins.telescope.enable); + message = '' + Telescope support for neorg is enabled but the telescope plugin is not. + ''; + } + { + when = (modules ? "core.defaults") && (!config.plugins.treesitter.enable); + message = '' + Neorg's `core.defaults` module is enabled but `plugins.treesitter` is not. + Treesitter is required when using the `core.defaults`. + ''; + } + ]; }; } diff --git a/plugins/by-name/none-ls/default.nix b/plugins/by-name/none-ls/default.nix index c0e328cc73..e70b562d13 100644 --- a/plugins/by-name/none-ls/default.nix +++ b/plugins/by-name/none-ls/default.nix @@ -126,13 +126,16 @@ lib.nixvim.plugins.mkNeovimPlugin { }; in { - warnings = lib.optional (cfg.enableLspFormat && cfg.settings.on_attach != null) '' - You have enabled the lsp-format integration with none-ls. - However, you have provided a custom value to `plugins.none-ls.settings.on_attach`. - This means the `enableLspFormat` option will have no effect. - Final value is: - ${lib.generators.toPretty { } cfg.settings.on_attach} - ''; + warnings = lib.nixvim.mkWarnings "plugins.none-ls" { + when = cfg.enableLspFormat && cfg.settings.on_attach != null; + message = '' + You have enabled the lsp-format integration with none-ls. + However, you have provided a custom value to `plugins.none-ls.settings.on_attach`. + This means the `enableLspFormat` option will have no effect. + Final value is: + ${lib.generators.toPretty { } cfg.settings.on_attach} + ''; + }; assertions = [ { diff --git a/plugins/by-name/none-ls/prettier.nix b/plugins/by-name/none-ls/prettier.nix index 523a458399..d07b660201 100644 --- a/plugins/by-name/none-ls/prettier.nix +++ b/plugins/by-name/none-ls/prettier.nix @@ -23,16 +23,18 @@ in }; config = lib.mkIf cfg.enable { - warnings = - lib.optional (opt.disableTsServerFormatter.highestPrio == defaultPrio && ts-ls-cfg.enable) - '' - You have enabled the `prettier` formatter in none-ls. - You have also enabled the `ts_ls` language server which also brings a formatting feature. + warnings = lib.nixvim.mkWarnings "plugins.none-ls.sources.formatting.prettier" { + when = opt.disableTsServerFormatter.highestPrio == defaultPrio && ts-ls-cfg.enable; - - To disable the formatter built-in the `ts_ls` language server, set - `plugins.none-ls.sources.formatting.prettier.disableTsServerFormatter` to `true`. - - Else, to silence this warning, explicitly set the option to `false`. - ''; + message = '' + You have enabled the `prettier` formatter in none-ls. + You have also enabled the `ts_ls` language server which also brings a formatting feature. + + - To disable the formatter built-in the `ts_ls` language server, set + `plugins.none-ls.sources.formatting.prettier.disableTsServerFormatter` to `true`. + - Else, to silence this warning, explicitly set the option to `false`. + ''; + }; plugins.lsp.servers.ts_ls = lib.mkIf (cfg.enable && ts-ls-cfg.enable && cfg.disableTsServerFormatter) diff --git a/plugins/by-name/none-ls/prettierd.nix b/plugins/by-name/none-ls/prettierd.nix index 3c61c4d727..3335183c3c 100644 --- a/plugins/by-name/none-ls/prettierd.nix +++ b/plugins/by-name/none-ls/prettierd.nix @@ -23,16 +23,18 @@ in }; config = lib.mkIf cfg.enable { - warnings = - lib.optional (opt.disableTsServerFormatter.highestPrio == defaultPrio && ts-ls-cfg.enable) - '' - You have enabled the `prettierd` formatter in none-ls. - You have also enabled the `ts_ls` language server which also brings a formatting feature. + warnings = lib.nixvim.mkWarnings "plugins.none-ls.sources.formatting.prettierd" { + when = opt.disableTsServerFormatter.highestPrio == defaultPrio && ts-ls-cfg.enable; - - To disable the formatter built-in the `ts_ls` language server, set - `plugins.none-ls.sources.formatting.prettierd.disableTsServerFormatter` to `true`. - - Else, to silence this warning, explicitly set the option to `false`. - ''; + message = '' + You have enabled the `prettierd` formatter in none-ls. + You have also enabled the `ts_ls` language server which also brings a formatting feature. + + - To disable the formatter built-in the `ts_ls` language server, set + `plugins.none-ls.sources.formatting.prettierd.disableTsServerFormatter` to `true`. + - Else, to silence this warning, explicitly set the option to `false`. + ''; + }; plugins.lsp.servers.ts_ls = lib.mkIf (cfg.enable && ts-ls-cfg.enable && cfg.disableTsServerFormatter) diff --git a/plugins/by-name/nvim-osc52/default.nix b/plugins/by-name/nvim-osc52/default.nix index 33aa0b9a5b..9552356fcb 100644 --- a/plugins/by-name/nvim-osc52/default.nix +++ b/plugins/by-name/nvim-osc52/default.nix @@ -76,14 +76,12 @@ with lib; }; in mkIf cfg.enable { - warnings = [ - '' - Nixvim(plugins.nvim-osc52): this plugin is obsolete and will be removed after 24.11. - As of Neovim 0.10, native support for OSC52 has been added. - See `:h clipboard-osc52` for more details: https://neovim.io/doc/user/provider.html#clipboard-osc52 - Definitions: ${lib.options.showDefs options.plugins.nvim-osc52.enable.definitionsWithLocations} - '' - ]; + warnings = lib.nixvim.mkWarnings "plugins.nvim-osc52" '' + This plugin is obsolete and will be removed after 24.11. + As of Neovim 0.10, native support for OSC52 has been added. + See `:h clipboard-osc52` for more details: https://neovim.io/doc/user/provider.html#clipboard-osc52 + Definitions: ${lib.options.showDefs options.plugins.nvim-osc52.enable.definitionsWithLocations} + ''; extraPlugins = [ cfg.package ]; diff --git a/plugins/by-name/otter/default.nix b/plugins/by-name/otter/default.nix index 0bfa1eb5a2..d2c2d3efc2 100644 --- a/plugins/by-name/otter/default.nix +++ b/plugins/by-name/otter/default.nix @@ -100,14 +100,15 @@ lib.nixvim.plugins.mkNeovimPlugin { }; extraConfig = cfg: { - warnings = - lib.optional - (config.plugins.treesitter.enable -> config.plugins.treesitter.settings.highlight.enable == null) + warnings = lib.nixvim.mkWarnings "plugins.otter" { + when = + config.plugins.treesitter.enable -> config.plugins.treesitter.settings.highlight.enable == null; - '' - NixVim(plugins.otter): you have enabled otter, but treesitter syntax highlighting is not enabled. - Otter functionality might not work as expected without it. Make sure `plugins.treesitter.settings.highlight.enable` and `plugins.treesitter.enable` are enabled. - ''; + message = '' + You have enabled otter, but treesitter syntax highlighting is not enabled. + Otter functionality might not work as expected without it. Make sure `plugins.treesitter.settings.highlight.enable` and `plugins.treesitter.enable` are enabled. + ''; + }; plugins.lsp.onAttach = lib.mkIf cfg.autoActivate '' require('otter').activate() diff --git a/plugins/by-name/persisted/default.nix b/plugins/by-name/persisted/default.nix index ea4a5b8857..9b773e432f 100644 --- a/plugins/by-name/persisted/default.nix +++ b/plugins/by-name/persisted/default.nix @@ -19,9 +19,12 @@ lib.nixvim.plugins.mkNeovimPlugin { }; extraConfig = cfg: { - warnings = lib.optional (cfg.enableTelescope && (!config.plugins.telescope.enable)) '' - Telescope support for `plugins.persisted` is enabled but the telescope plugin is not. - ''; + warnings = lib.nixvim.mkWarnings "plugins.persisted" { + when = cfg.enableTelescope && (!config.plugins.telescope.enable); + message = '' + Telescope support (enableTelescope) is enabled but the telescope plugin is not. + ''; + }; plugins.telescope.enabledExtensions = lib.mkIf cfg.enableTelescope [ "persisted" ]; }; diff --git a/plugins/by-name/project-nvim/default.nix b/plugins/by-name/project-nvim/default.nix index fb23367f7a..ab23cba2e8 100644 --- a/plugins/by-name/project-nvim/default.nix +++ b/plugins/by-name/project-nvim/default.nix @@ -120,9 +120,12 @@ lib.nixvim.plugins.mkNeovimPlugin { }; extraConfig = cfg: { - warnings = lib.optional (cfg.enableTelescope && (!config.plugins.telescope.enable)) '' - Telescope support for project-nvim is enabled but the telescope plugin is not. - ''; + warnings = lib.nixvim.mkWarnings "plugins.project-nvim" { + when = cfg.enableTelescope && (!config.plugins.telescope.enable); + message = '' + Telescope support (enableTelescope) is enabled but the telescope plugin is not. + ''; + }; plugins.telescope.enabledExtensions = lib.mkIf cfg.enableTelescope [ "projects" ]; }; diff --git a/plugins/by-name/rainbow-delimiters/default.nix b/plugins/by-name/rainbow-delimiters/default.nix index 2bf722c384..8dde51c037 100644 --- a/plugins/by-name/rainbow-delimiters/default.nix +++ b/plugins/by-name/rainbow-delimiters/default.nix @@ -115,9 +115,10 @@ with lib; cfg = config.plugins.rainbow-delimiters; in mkIf cfg.enable { - warnings = optional ( - !config.plugins.treesitter.enable - ) "Nixvim: treesitter-rainbow needs treesitter to function as intended"; + warnings = lib.nixvim.mkWarnings "plugins.rainbow-delimiters" { + when = !config.plugins.treesitter.enable; + message = "This plugin needs treesitter to function as intended."; + }; assertions = [ { assertion = (cfg.whitelist == null) || (cfg.blacklist == null); diff --git a/plugins/by-name/schemastore/default.nix b/plugins/by-name/schemastore/default.nix index d283443000..a5569ea8c4 100644 --- a/plugins/by-name/schemastore/default.nix +++ b/plugins/by-name/schemastore/default.nix @@ -122,16 +122,20 @@ lib.nixvim.plugins.mkVimPlugin { }; extraConfig = cfg: { - warnings = - (optional (!(cfg.json.enable || cfg.yaml.enable)) '' - NixVim(plugins.schemastore): you have enabled the plugin, but neither `json` or `yaml` schemas are enabled. - '') - ++ (optional (!(cfg.json.enable -> config.plugins.lsp.servers.jsonls.enable)) '' - NixVim(plugins.schemastore): you have enabled `json` schemas, but `plugins.lsp.servers.jsonls` is not enabled. - '') - ++ (optional (!(cfg.yaml.enable -> config.plugins.lsp.servers.yamlls.enable)) '' - NixVim(plugins.schemastore): you have enabled `yaml` schemas, but `plugins.lsp.servers.yamlls` is not enabled. - ''); + warnings = lib.nixvim.mkWarnings "plugins.schemastore" [ + { + when = !(cfg.json.enable || cfg.yaml.enable); + message = "You have enabled the plugin, but neither `json` or `yaml` schemas are enabled."; + } + { + when = !(cfg.json.enable -> config.plugins.lsp.servers.jsonls.enable); + message = "You have enabled `json` schemas, but `plugins.lsp.servers.jsonls` is not enabled."; + } + { + when = !(cfg.yaml.enable -> config.plugins.lsp.servers.yamlls.enable); + message = "You have enabled `yaml` schemas, but `plugins.lsp.servers.yamlls` is not enabled."; + } + ]; plugins.lsp.servers = { jsonls.settings = mkIf cfg.json.enable { diff --git a/plugins/by-name/treesitter-context/default.nix b/plugins/by-name/treesitter-context/default.nix index 2074a125b6..843ec569a2 100644 --- a/plugins/by-name/treesitter-context/default.nix +++ b/plugins/by-name/treesitter-context/default.nix @@ -97,8 +97,9 @@ lib.nixvim.plugins.mkNeovimPlugin { }; extraConfig = { - warnings = mkIf (!config.plugins.treesitter.enable) [ - "Nixvim: treesitter-context needs treesitter to function as intended" - ]; + warnings = lib.nixvim.mkWarnings "plugins.treesitter-context" { + when = !config.plugins.treesitter.enable; + message = "This plugin needs treesitter to function as intended."; + }; }; } diff --git a/plugins/by-name/treesitter-refactor/default.nix b/plugins/by-name/treesitter-refactor/default.nix index 5ab0c1ff05..4e98c240d6 100644 --- a/plugins/by-name/treesitter-refactor/default.nix +++ b/plugins/by-name/treesitter-refactor/default.nix @@ -143,9 +143,10 @@ with lib; cfg = config.plugins.treesitter-refactor; in mkIf cfg.enable { - warnings = mkIf (!config.plugins.treesitter.enable) [ - "Nixvim: treesitter-refactor needs treesitter to function as intended" - ]; + warnings = lib.nixvim.mkWarnings "plugins.treesitter-refactor" { + when = !config.plugins.treesitter.enable; + message = "This plugin needs treesitter to function as intended."; + }; extraPlugins = [ cfg.package ]; diff --git a/plugins/by-name/treesitter-textobjects/default.nix b/plugins/by-name/treesitter-textobjects/default.nix index 65e13020ef..2dcf9eff3a 100644 --- a/plugins/by-name/treesitter-textobjects/default.nix +++ b/plugins/by-name/treesitter-textobjects/default.nix @@ -192,9 +192,10 @@ with lib; cfg = config.plugins.treesitter-textobjects; in mkIf cfg.enable { - warnings = mkIf (!config.plugins.treesitter.enable) [ - "Nixvim: treesitter-textobjects needs treesitter to function as intended" - ]; + warnings = lib.nixvim.mkWarnings "plugins.treesitter-textobjects" { + when = !config.plugins.treesitter.enable; + message = "This plugin needs treesitter to function as intended."; + }; extraPlugins = [ cfg.package ]; diff --git a/plugins/by-name/trouble/default.nix b/plugins/by-name/trouble/default.nix index 05cd9e3078..a40d66d557 100644 --- a/plugins/by-name/trouble/default.nix +++ b/plugins/by-name/trouble/default.nix @@ -371,10 +371,13 @@ lib.nixvim.plugins.mkNeovimPlugin { "use_diagnostic_signs" ]; in - lib.optional (definedOpts != [ ]) '' - Nixvim(plugins.trouble): 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.trouble" { + 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: added 2024-09-20 remove after 24.11 plugins.web-devicons = lib.mkIf ( diff --git a/plugins/by-name/ts-autotag/default.nix b/plugins/by-name/ts-autotag/default.nix index a30db9f633..a413625f54 100644 --- a/plugins/by-name/ts-autotag/default.nix +++ b/plugins/by-name/ts-autotag/default.nix @@ -37,9 +37,10 @@ lib.nixvim.plugins.mkNeovimPlugin { ]; extraConfig = { - warnings = mkIf (!config.plugins.treesitter.enable) [ - "Nixvim: ts-autotag needs treesitter to function as intended" - ]; + warnings = lib.nixvim.mkWarnings "plugins.ts-autotag" { + when = !config.plugins.treesitter.enable; + message = "This plugin needs treesitter to function as intended."; + }; }; settingsOptions = diff --git a/plugins/by-name/ts-context-commentstring/default.nix b/plugins/by-name/ts-context-commentstring/default.nix index 930fd0de78..c63dc0ac4a 100644 --- a/plugins/by-name/ts-context-commentstring/default.nix +++ b/plugins/by-name/ts-context-commentstring/default.nix @@ -42,9 +42,10 @@ with lib; cfg = config.plugins.ts-context-commentstring; in mkIf cfg.enable { - warnings = mkIf (!config.plugins.treesitter.enable) [ - "Nixvim: ts-context-commentstring needs treesitter to function as intended" - ]; + warnings = lib.nixvim.mkWarnings "plugins.ts-context-commentstring" { + when = !config.plugins.treesitter.enable; + message = "This plugin needs treesitter to function as intended."; + }; extraPlugins = [ cfg.package ]; diff --git a/plugins/by-name/typescript-tools/default.nix b/plugins/by-name/typescript-tools/default.nix index 50dfe0971f..ad08f93f8b 100644 --- a/plugins/by-name/typescript-tools/default.nix +++ b/plugins/by-name/typescript-tools/default.nix @@ -265,9 +265,12 @@ lib.nixvim.plugins.mkNeovimPlugin { # TODO:: introduced 10-22-2024: remove after 24.11 # Nested settings can't have normal mkRenamedOptionModule functionality so we can only # alert the user that they are using the old values - warnings = lib.optional (definedOpts != [ ]) '' - Nixvim(plugins.typescript-tools): The following settings have moved under `plugins.typescript-tools.settings.settings` with snake_case: - ${lib.concatMapStringsSep "\n" (opt: " - ${lib.showOption (lib.toList opt)}") definedOpts} - ''; + warnings = lib.nixvim.mkWarnings "plugins.typescript-tools" { + when = definedOpts != [ ]; + message = '' + The following settings have moved under `plugins.typescript-tools.settings.settings` with snake_case: + ${lib.concatMapStringsSep "\n" (opt: " - ${lib.showOption (lib.toList opt)}") definedOpts} + ''; + }; }; } diff --git a/plugins/by-name/which-key/default.nix b/plugins/by-name/which-key/default.nix index a6b1f7045a..7c086db44c 100644 --- a/plugins/by-name/which-key/default.nix +++ b/plugins/by-name/which-key/default.nix @@ -451,16 +451,13 @@ lib.nixvim.plugins.mkNeovimPlugin { extraConfig = cfg: opts: lib.mkIf opts.registrations.isDefined { - warnings = [ - '' - nixvim (plugins.which-key): - The option definition `plugins.which-key.registrations' in ${showFiles opts.registrations.files} has been deprecated in which-key v3; please remove it. - You should use `plugins.which-key.settings.spec' instead. + warnings = lib.nixvim.mkWarnings "plugins.which-key" '' + The option definition `plugins.which-key.registrations' in ${showFiles opts.registrations.files} has been deprecated in which-key v3; please remove it. + You should use `plugins.which-key.settings.spec' instead. - Note: the spec format has changed in which-key v3 - See: https://github.com/folke/which-key.nvim?tab=readme-ov-file#%EF%B8%8F-mappings - '' - ]; + Note: the spec format has changed in which-key v3 + See: https://github.com/folke/which-key.nvim?tab=readme-ov-file#%EF%B8%8F-mappings + ''; plugins.which-key.luaConfig.content = lib.optionalString opts.registrations.isDefined '' require("which-key").register(${toLuaObject cfg.registrations}) diff --git a/plugins/deprecation.nix b/plugins/deprecation.nix index 66c0274e78..e946bd300e 100644 --- a/plugins/deprecation.nix +++ b/plugins/deprecation.nix @@ -62,23 +62,28 @@ in { config = { warnings = - lib.optionals (options.plugins.web-devicons.enable.highestPrio == 1490) [ - '' - Nixvim: `plugins.web-devicons` was enabled automatically because the following plugins are enabled. + (lib.nixvim.mkWarnings "plugins.web-devicons" { + when = options.plugins.web-devicons.enable.highestPrio == 1490; + + message = '' + This plugin was enabled automatically because the following plugins are enabled. This behaviour is deprecated. Please explicitly define `plugins.web-devicons.enable` or alternatively enable `plugins.mini.enable` with `plugins.mini.modules.icons` and `plugins.mini.mockDevIcons`. ${lib.concatMapStringsSep "\n" (name: "plugins.${name}") ( builtins.filter (name: config.plugins.${name}.enable) iconsPackagePlugins )} - '' - ] + ''; + }) ++ lib.foldlAttrs ( warnings: plugin: msg: warnings - ++ lib.optional config.plugins.${plugin}.enable '' - Nixvim Warning: The `${plugin}` plugin has been deprecated. - ${msg} - '' + ++ (lib.nixvim.mkWarnings "plugins.${plugin}" { + when = config.plugins.${plugin}.enable; + message = '' + This plugin has been deprecated. + ${msg} + ''; + }) ) [ ] deprecated; }; } diff --git a/plugins/lsp/language-servers/hls.nix b/plugins/lsp/language-servers/hls.nix index e738dec0e5..0da395a03a 100644 --- a/plugins/lsp/language-servers/hls.nix +++ b/plugins/lsp/language-servers/hls.nix @@ -21,13 +21,16 @@ in }; config = lib.mkIf cfg.enable { - warnings = lib.optional (cfg.installGhc == null) '' - `hls` relies on `ghc` (the Glasgow Haskell Compiler). - - Set `plugins.lsp.servers.hls.installGhc = true` to install it automatically with Nixvim. - You can customize which package to install by changing `plugins.lsp.servers.hls.ghcPackage`. - - Set `plugins.lsp.servers.hls.installGhc = false` to not have it install through Nixvim. - By doing so, you will dismiss this warning. - ''; + warnings = lib.nixvim.mkWarnings "plugins.lsp.servers.hls" { + when = cfg.installGhc == null; + message = '' + `hls` relies on `ghc` (the Glasgow Haskell Compiler). + - Set `plugins.lsp.servers.hls.installGhc = true` to install it automatically with Nixvim. + You can customize which package to install by changing `plugins.lsp.servers.hls.ghcPackage`. + - Set `plugins.lsp.servers.hls.installGhc = false` to not have it install through Nixvim. + By doing so, you will dismiss this warning. + ''; + }; extraPackages = lib.optional ((lib.isBool cfg.installGhc) && cfg.installGhc) cfg.ghcPackage; }; diff --git a/plugins/lsp/language-servers/rust-analyzer.nix b/plugins/lsp/language-servers/rust-analyzer.nix index 42de53bf59..4426ead090 100644 --- a/plugins/lsp/language-servers/rust-analyzer.nix +++ b/plugins/lsp/language-servers/rust-analyzer.nix @@ -41,27 +41,36 @@ in rustfmtPackage = mkPackageOption pkgs "rustfmt" { }; }; config = lib.mkIf cfg.enable { - warnings = - (lib.optional (cfg.installCargo == null) '' - `rust_analyzer` relies on `cargo`. - - Set `plugins.lsp.servers.rust_analyzer.installCargo = true` to install it automatically - with Nixvim. - You can customize which package to install by changing - `plugins.lsp.servers.rust_analyzer.cargoPackage`. - - Set `plugins.lsp.servers.rust_analyzer.installCargo = false` to not have it install - through Nixvim. - By doing so, you will dismiss this warning. - '') - ++ (lib.optional (cfg.installRustc == null) '' - `rust_analyzer` relies on `rustc`. - - Set `plugins.lsp.servers.rust_analyzer.installRustc = true` to install it automatically - with Nixvim. - You can customize which package to install by changing - `plugins.lsp.servers.rust_analyzer.rustcPackage`. - - Set `plugins.lsp.servers.rust_analyzer.installRustc = false` to not have it install - through Nixvim. - By doing so, you will dismiss this warning. - ''); + warnings = lib.nixvim.mkWarnings "plugins.lsp.servers.rust_analyzer" [ + { + when = cfg.installCargo == null; + + message = '' + `rust_analyzer` relies on `cargo`. + - Set `plugins.lsp.servers.rust_analyzer.installCargo = true` to install it automatically + with Nixvim. + You can customize which package to install by changing + `plugins.lsp.servers.rust_analyzer.cargoPackage`. + - Set `plugins.lsp.servers.rust_analyzer.installCargo = false` to not have it install + through Nixvim. + By doing so, you will dismiss this warning. + ''; + } + { + when = cfg.installRustc == null; + + message = '' + `rust_analyzer` relies on `rustc`. + - Set `plugins.lsp.servers.rust_analyzer.installRustc = true` to install it automatically + with Nixvim. + You can customize which package to install by changing + `plugins.lsp.servers.rust_analyzer.rustcPackage`. + - Set `plugins.lsp.servers.rust_analyzer.installRustc = false` to not have it install + through Nixvim. + By doing so, you will dismiss this warning. + ''; + } + ]; extraPackages = let diff --git a/tests/test-sources/plugins/by-name/nvim-osc52/default.nix b/tests/test-sources/plugins/by-name/nvim-osc52/default.nix index c275e81875..26a00fed54 100644 --- a/tests/test-sources/plugins/by-name/nvim-osc52/default.nix +++ b/tests/test-sources/plugins/by-name/nvim-osc52/default.nix @@ -2,7 +2,7 @@ let # This plugin is deprecated warnings = expect: [ (expect "count" 1) - (expect "any" "this plugin is obsolete and will be removed after 24.11.") + (expect "any" "This plugin is obsolete and will be removed after 24.11.") ]; in {