treewide: use mkAssertions where possible

This commit is contained in:
Gaetan Lepage 2025-01-29 15:50:36 +01:00
parent 12e658eca8
commit ce82e5859d
14 changed files with 94 additions and 104 deletions

View file

@ -176,15 +176,13 @@ lib.nixvim.plugins.mkNeovimPlugin {
};
extraConfig = {
assertions = [
{
assertion = !config.plugins.copilot-vim.enable;
message = ''
You currently have both `copilot-vim` and `copilot-lua` enabled.
Please disable one of them.
'';
}
];
assertions = lib.nixvim.mkAssertions "plugins.copilot-lua" {
assertion = !config.plugins.copilot-vim.enable;
message = ''
You currently have both `copilot-vim` and `copilot-lua` enabled.
Please disable one of them.
'';
};
};
# TODO: introduced 2025-01-07: remove after 25.05

View file

@ -59,12 +59,12 @@ lib.nixvim.plugins.mkNeovimPlugin {
extraConfig =
cfg:
lib.mkIf cfg.enable {
assertions = [
{
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
message = ''Nixvim: The git-worktree telescope integration needs telescope to function as intended'';
}
];
assertions = lib.nixvim.mkAssertions "plugins.git-worktree" {
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
message = ''
You have to enable `plugins.telescope` as `enableTelescope` is activated.
'';
};
extraPackages = [ cfg.gitPackage ];

View file

@ -191,10 +191,10 @@ in
// cfg.extraOptions;
in
mkIf cfg.enable {
assertions = [
assertions = lib.nixvim.mkAssertions "plugins.harpoon" [
{
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
message = ''Nixvim: The harpoon telescope integration needs telescope to function as intended'';
message = "The harpoon telescope integration needs telescope to function as intended.";
}
];

View file

@ -231,29 +231,27 @@ in
config = mkIf cfg.enable {
extraPlugins = [ cfg.package ];
assertions = [
{
assertion =
!(
# leanls lsp server is disabled in nvim-lspconfig
config.plugins.lsp.servers.leanls.enable
# lsp is not (!) disabled in the lean.nvim plugin
&& !(
# lsp is explicitly set to `false`.
(isBool cfg.lsp.enable) && !cfg.lsp.enable
)
);
message = ''
You have not explicitly set `plugins.lean.lsp` to `false` while having `plugins.lsp.servers.leanls.enable` set to `true`.
You need to either
assertions = lib.nixvim.mkAssertions "plugins.lean" {
assertion =
!(
# leanls lsp server is disabled in nvim-lspconfig
config.plugins.lsp.servers.leanls.enable
# lsp is not (!) disabled in the lean.nvim plugin
&& !(
# lsp is explicitly set to `false`.
(isBool cfg.lsp.enable) && !cfg.lsp.enable
)
);
message = ''
You have not explicitly set `plugins.lean.lsp` to `false` while having `plugins.lsp.servers.leanls.enable` set to `true`.
You need to either
- Remove the configuration in `plugins.lsp.servers.leanls` and move it to `plugins.lean.lsp`.
- Explicitly disable the autoconfiguration of the lsp in the lean.nvim plugin by setting `plugins.lean.lsp` to `false`.
- Remove the configuration in `plugins.lsp.servers.leanls` and move it to `plugins.lean.lsp`.
- Explicitly disable the autoconfiguration of the lsp in the lean.nvim plugin by setting `plugins.lean.lsp` to `false`.
https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#leanls
'';
}
];
https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#leanls
'';
};
extraPackages = [ cfg.leanPackage ];

View file

@ -94,15 +94,14 @@ lib.nixvim.plugins.mkNeovimPlugin {
callSetup = false;
hasSettings = false;
extraConfig = cfg: {
assertions = [
{
assertion = cfg.mockDevIcons -> cfg.modules ? icons;
message = ''
You have enabled `plugins.mini.mockDevIcons` but have not defined `plugins.mini.modules.icons`.
This setting will have no effect without it.
'';
}
];
assertions = lib.nixvim.mkAssertions "pluhins.mini" {
assertion = cfg.mockDevIcons -> cfg.modules ? icons;
message = ''
You have enabled `plugins.mini.mockDevIcons` but have not defined `plugins.mini.modules.icons`.
This setting will have no effect without it.
'';
};
plugins.mini.luaConfig.content =
lib.foldlAttrs (lines: name: config: ''
${lines}

View file

@ -37,12 +37,12 @@ let
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
assertions = [
{
assertion = config.plugins.neotest.enable;
message = "Nixvim: you have enabled `plugins.neotest.adapters.${name}` but `plugins.neotest.enable` is `false`.";
}
];
assertions = lib.nixvim.mkAssertions "plugins.neotest.adapters.${name}" {
assertion = config.plugins.neotest.enable;
message = ''
You have to enable `plugins.telescope` as `enableTelescope` is activated.
'';
};
warnings = lib.nixvim.mkWarnings "plugins.neotest.adapters.${name}" {
when = !config.plugins.treesitter.enable;

View file

@ -137,17 +137,16 @@ lib.nixvim.plugins.mkNeovimPlugin {
'';
};
assertions = [
{
assertion = cfg.enableLspFormat -> config.plugins.lsp-format.enable;
message = ''
Nixvim: You have enabled the lsp-format integration with none-ls.
However, you have not enabled `plugins.lsp-format` itself.
Note: `plugins.none-ls.enableLspFormat` is enabled by default when `plugins.lsp-format` is enabled.
`plugins.none-ls.enableLspFormat` definitions: ${lib.options.showDefs options.plugins.none-ls.enableLspFormat.definitionsWithLocations}
'';
}
];
assertions = lib.nixvim.mkAssertions "plugins.none-ls" {
assertion = cfg.enableLspFormat -> config.plugins.lsp-format.enable;
message = ''
You have enabled the lsp-format integration with none-ls.
However, you have not enabled `plugins.lsp-format` itself.
Note: `plugins.none-ls.enableLspFormat` is enabled by default when `plugins.lsp-format` is enabled.
`plugins.none-ls.enableLspFormat` definitions: ${lib.options.showDefs options.plugins.none-ls.enableLspFormat.definitionsWithLocations}
'';
};
# We only do this here because of enableLspFormat
plugins.none-ls.luaConfig.content = ''

View file

@ -111,7 +111,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
assertions = lib.nixvim.mkAssertions "plugins.package-info" {
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
message = ''
The telescope integration needs telescope to function as intended.
You have to enable `plugins.telescope` as `enableTelescope` is activated.
'';
};

View file

@ -119,16 +119,15 @@ with lib;
when = !config.plugins.treesitter.enable;
message = "This plugin needs treesitter to function as intended.";
};
assertions = [
{
assertion = (cfg.whitelist == null) || (cfg.blacklist == null);
message = ''
Both `rainbow-delimiters.whitelist` and `rainbow-delimiters.blacklist` should not be
set simultaneously.
Please remove one of them.
'';
}
];
assertions = lib.nixvim.mkAssertions "plugins.rainbow-delimiters" {
assertion = (cfg.whitelist == null) || (cfg.blacklist == null);
message = ''
Both `rainbow-delimiters.whitelist` and `rainbow-delimiters.blacklist` should not be
set simultaneously.
Please remove one of them.
'';
};
extraPlugins = [ cfg.package ];

View file

@ -26,15 +26,14 @@ lib.nixvim.plugins.mkNeovimPlugin {
};
extraConfig = cfg: {
assertions = [
{
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
message = ''
Nixvim: You have enabled the `telescope` integration with refactoring-nvim.
However, you have not enabled the `telescope` plugin itself (`plugins.telescope.enable = true`).
'';
}
];
assertions = lib.nixvim.mkAssertions "plugins.refactoring" {
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
message = ''
You have enabled the `telescope` integration with refactoring-nvim.
However, you have not enabled the `telescope` plugin itself (`plugins.telescope.enable = true`).
'';
};
plugins.telescope.enabledExtensions = mkIf cfg.enableTelescope [ "refactoring" ];
};

View file

@ -27,7 +27,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
assertions = lib.nixvim.mkAssertions "plugins.telekasten" {
assertion = config.plugins.telescope.enable;
message = ''
Nixvim (plugins.telekasten): The plugin needs telescope to function as intended.
You have to enable `plugins.telescope` as `enableTelescope` is activated.
'';
};

View file

@ -90,20 +90,18 @@ lib.nixvim.plugins.mkNeovimPlugin {
};
extraConfig = {
assertions = [
{
assertion =
config.plugins.web-devicons.enable
|| (
config.plugins.mini.enable
&& config.plugins.mini.modules ? icons
&& config.plugins.mini.mockDevIcons
);
message = ''
Nixvim: Either `plugins.web-devicons` or `plugins.mini`* must be enabled to use `tiny-devicons-auto-colors`.
*If using `plugins.mini`, you must enable the `icons` module and the `mockDevIcons` option.
'';
}
];
assertions = lib.nixvim.mkAssertions "plugins.tiny-devicons-auto-colors" {
assertion =
config.plugins.web-devicons.enable
|| (
config.plugins.mini.enable
&& config.plugins.mini.modules ? icons
&& config.plugins.mini.mockDevIcons
);
message = ''
Either `plugins.web-devicons` or `plugins.mini`* must be enabled to use `tiny-devicons-auto-colors`.
*If using `plugins.mini`, you must enable the `icons` module and the `mockDevIcons` option.
'';
};
};
}

View file

@ -414,18 +414,18 @@ lib.nixvim.plugins.mkNeovimPlugin {
};
extraConfig = cfg: {
assertions = [
assertions = lib.nixvim.mkAssertions "plugins.todo-comments" [
{
assertion = cfg.keymaps.todoTelescope.key or null != null -> config.plugins.telescope.enable;
message = ''
Nixvim(plugins.todo-comments): You have enabled todo-comment's `telescope` integration.
You have enabled todo-comment's `telescope` integration.
However, you have not enabled the `telescope` plugin itself (`plugins.telescope.enable = true`).
'';
}
{
assertion = cfg.keymaps.todoTrouble.key or null != null -> config.plugins.trouble.enable;
message = ''
Nixvim(plugins.todo-comments): You have enabled todo-comment's `trouble` integration.
You have enabled todo-comment's `trouble` integration.
However, you have not enabled the `trouble` plugin itself (`plugins.trouble.enable = true`).
'';
}

View file

@ -363,7 +363,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
{
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
message = ''
The telescope integration needs telescope to function as intended
You have to enable `plugins.telescope` as `enableTelescope` is activated.
'';
}
{