treewide: use mkWarnings wherever possible

This commit is contained in:
Gaetan Lepage 2025-01-17 16:18:38 +01:00 committed by nix-infra-bot
parent 02e16b2a76
commit 2ec6218f87
7 changed files with 72 additions and 59 deletions

View file

@ -1,10 +1,8 @@
{ {
lib, lib,
helpers,
config, config,
... ...
}: }:
with lib;
lib.nixvim.plugins.mkVimPlugin { lib.nixvim.plugins.mkVimPlugin {
name = "haskell-scope-highlighting"; name = "haskell-scope-highlighting";
packPathName = "haskell-scope-highlighting.nvim"; packPathName = "haskell-scope-highlighting.nvim";
@ -13,9 +11,12 @@ lib.nixvim.plugins.mkVimPlugin {
maintainers = [ lib.maintainers.GaetanLepage ]; maintainers = [ lib.maintainers.GaetanLepage ];
extraConfig = { extraConfig = {
warnings = optional (!config.plugins.treesitter.enable) '' warnings = lib.nixvim.mkWarnings "plugins.haskell-scope-highlighting" {
Nixvim (plugins.haskell-scope-highlighting): haskell-scope-highlighting needs treesitter to function as intended. when = !config.plugins.treesitter.enable;
Please, enable it by setting `plugins.treesitter.enable` to `true`. message = ''
''; haskell-scope-highlighting needs treesitter to function as intended.
Please, enable it by setting `plugins.treesitter.enable` to `true`.
'';
};
}; };
} }

View file

@ -189,12 +189,12 @@ lib.nixvim.plugins.mkNeovimPlugin {
}; };
extraConfig = cfg: { extraConfig = cfg: {
warnings = warnings = lib.nixvim.mkWarnings "plugins.nvim-autopairs" {
optional when = (isBool cfg.settings.check_ts) && cfg.settings.check_ts && !config.plugins.treesitter.enable;
((isBool cfg.settings.check_ts) && cfg.settings.check_ts && !config.plugins.treesitter.enable) message = ''
'' You have set `settings.check_ts` to `true` but have not enabled the treesitter plugin.
Nixvim (plugins.nvim-autopairs): You have set `settings.check_ts` to `true` but have not enabled the treesitter plugin. We suggest you to set `plugins.treesitter.enable` to `true`.
We suggest you to set `plugins.treesitter.enable` to `true`. '';
''; };
}; };
} }

View file

@ -249,13 +249,16 @@ lib.nixvim.plugins.mkNeovimPlugin {
}; };
extraConfig = cfg: { extraConfig = cfg: {
warnings = warnings = lib.nixvim.mkWarnings "plugins.obsidian" {
let when =
nvimCmpEnabled = isBool cfg.settings.completion.nvim_cmp && cfg.settings.completion.nvim_cmp; let
in nvimCmpEnabled = isBool cfg.settings.completion.nvim_cmp && cfg.settings.completion.nvim_cmp;
optional (nvimCmpEnabled && !config.plugins.cmp.enable) '' in
Nixvim (plugins.obsidian): You have enabled `completion.nvim_cmp` but `plugins.cmp.enable` is `false`. nvimCmpEnabled && (!config.plugins.cmp.enable);
message = ''
You have enabled `completion.nvim_cmp` but `plugins.cmp.enable` is `false`.
You should probably enable `nvim-cmp`. You should probably enable `nvim-cmp`.
''; '';
};
}; };
} }

View file

@ -68,19 +68,19 @@ lib.nixvim.plugins.mkNeovimPlugin {
]; ];
# TODO: remove after 24.11 # TODO: remove after 24.11
warnings = warnings = lib.nixvim.mkWarnings "plugins.rustaceanvim" {
optional when = hasAttrByPath [
(hasAttrByPath [ "settings"
"settings" "server"
"server" "settings"
"settings" ] cfg;
] cfg) message = ''
'' The `settings.server.settings' option has been renamed to `settings.server.default_settings'.
The `plugins.rustaceanvim.settings.server.settings' option has been renamed to `plugins.rustaceanvim.settings.server.default_settings'.
Note that if you supplied an attrset and not a function you need to set this attr set in: Note that if you supplied an attrset and not a function you need to set this attr set in:
`plugins.rustaceanvim.settings.server.default_settings.rust-analyzer'. `settings.server.default_settings.rust-analyzer'.
''; '';
};
} }
# If nvim-lspconfig is enabled: # If nvim-lspconfig is enabled:
(mkIf config.plugins.lsp.enable { (mkIf config.plugins.lsp.enable {

View file

@ -70,11 +70,12 @@ lib.nixvim.plugins.mkNeovimPlugin {
}; };
extraConfig = cfg: { extraConfig = cfg: {
warnings = warnings = lib.nixvim.mkWarnings "plugins.twilight" {
optional when =
((isBool cfg.settings.treesitter) && cfg.settings.treesitter && (!config.plugins.treesitter.enable)) (isBool cfg.settings.treesitter) && cfg.settings.treesitter && (!config.plugins.treesitter.enable);
'' message = ''
Nixvim (plugins.twilight): You have set `plugins.twilight.treesitter` to `true` but `plugins.treesitter.enable` is false. You have set `plugins.twilight.treesitter` to `true` but `plugins.treesitter.enable` is false.
''; '';
};
}; };
} }

View file

@ -58,22 +58,29 @@ in
config = lib.mkIf (cfg.enable && cfg.autoEnableSources) ( config = lib.mkIf (cfg.enable && cfg.autoEnableSources) (
lib.mkMerge [ lib.mkMerge [
{ {
warnings = warnings = lib.nixvim.mkWarnings "plugins.cmp" [
# TODO: expand this warning to ft & cmd sources lists and `showDefs` the offending definitions # TODO: expand this warning to ft & cmd sources lists and `showDefs` the offending definitions
lib.optional (lib.types.isRawType cfg.settings.sources) '' {
Nixvim (plugins.cmp): You have enabled `autoEnableSources` that tells Nixvim to automatically when = lib.types.isRawType cfg.settings.sources;
enable the source plugins with respect to the list of sources provided in `settings.sources`. message = ''
However, the latter is proveded as a raw lua string which is not parseable by Nixvim. You have enabled `autoEnableSources` that tells Nixvim to automatically
enable the source plugins with respect to the list of sources provided in `settings.sources`.
However, the latter is proveded as a raw lua string which is not parseable by Nixvim.
If you want to keep using raw lua for defining your sources: If you want to keep using raw lua for defining your sources:
- Ensure you enable the relevant plugins manually in your configuration; - Ensure you enable the relevant plugins manually in your configuration;
- Dismiss this warning by explicitly setting `autoEnableSources` to `false`; - Dismiss this warning by explicitly setting `autoEnableSources` to `false`;
'' '';
}
# TODO: Added 2024-09-22; remove after 24.11 # TODO: Added 2024-09-22; remove after 24.11
++ lib.optional (lib.elem "otter" enabledSources) '' {
Nixvim (plugins.cmp): "otter" is listed in `settings.sources`, however it is no longer a cmp source. when = lib.elem "otter" enabledSources;
Instead, you should enable `plugins.otter` and use the "cmp-nvim-lsp" completion source. message = ''
''; "otter" is listed in `settings.sources`, however it is no longer a cmp source.
Instead, you should enable `plugins.otter` and use the "cmp-nvim-lsp" completion source.
'';
}
];
# If the user has enabled the `foo` and `bar` sources, then `plugins` will look like: # If the user has enabled the `foo` and `bar` sources, then `plugins` will look like:
# { # {

View file

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