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,
helpers,
config,
...
}:
with lib;
lib.nixvim.plugins.mkVimPlugin {
name = "haskell-scope-highlighting";
packPathName = "haskell-scope-highlighting.nvim";
@ -13,9 +11,12 @@ lib.nixvim.plugins.mkVimPlugin {
maintainers = [ lib.maintainers.GaetanLepage ];
extraConfig = {
warnings = optional (!config.plugins.treesitter.enable) ''
Nixvim (plugins.haskell-scope-highlighting): haskell-scope-highlighting needs treesitter to function as intended.
Please, enable it by setting `plugins.treesitter.enable` to `true`.
'';
warnings = lib.nixvim.mkWarnings "plugins.haskell-scope-highlighting" {
when = !config.plugins.treesitter.enable;
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: {
warnings =
optional
((isBool cfg.settings.check_ts) && cfg.settings.check_ts && !config.plugins.treesitter.enable)
''
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`.
'';
warnings = lib.nixvim.mkWarnings "plugins.nvim-autopairs" {
when = (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.
We suggest you to set `plugins.treesitter.enable` to `true`.
'';
};
};
}

View file

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

View file

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

View file

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