treewide: use boolean comparison to simplify the code base

This commit is contained in:
Gaetan Lepage 2025-01-29 17:42:54 +01:00
parent 5066c71549
commit e908e344f4
18 changed files with 29 additions and 64 deletions

View file

@ -48,18 +48,17 @@ lib.nixvim.plugins.mkNeovimPlugin {
warnings = warnings =
let let
copilot-lua-cfg = config.plugins.copilot-lua.settings; copilot-lua-cfg = config.plugins.copilot-lua.settings;
isEnabled = b: builtins.isBool b && b;
in in
lib.nixvim.mkWarnings "plugins.blink-cmp-copilot" [ lib.nixvim.mkWarnings "plugins.blink-cmp-copilot" [
{ {
when = isEnabled copilot-lua-cfg.suggestion.enabled; when = copilot-lua-cfg.suggestion.enabled == true;
message = '' message = ''
It is recommended to disable copilot's `suggestion` module, as it can interfere with It is recommended to disable copilot's `suggestion` module, as it can interfere with
completions properly appearing in blink-cmp-copilot. completions properly appearing in blink-cmp-copilot.
''; '';
} }
{ {
when = isEnabled copilot-lua-cfg.panel.enabled; when = copilot-lua-cfg.panel.enabled == true;
message = '' message = ''
It is recommended to disable copilot's `panel` module, as it can interfere with completions It is recommended to disable copilot's `panel` module, as it can interfere with completions
properly appearing in blink-cmp-copilot. properly appearing in blink-cmp-copilot.

View file

@ -58,18 +58,17 @@ lib.nixvim.plugins.mkNeovimPlugin {
warnings = warnings =
let let
copilot-lua-cfg = config.plugins.copilot-lua.settings; copilot-lua-cfg = config.plugins.copilot-lua.settings;
isEnabled = b: (lib.isBool b && b);
in in
lib.nixvim.mkWarnings "plugins.copilot-cmp" [ lib.nixvim.mkWarnings "plugins.copilot-cmp" [
{ {
when = isEnabled copilot-lua-cfg.suggestion.enabled; when = copilot-lua-cfg.suggestion.enabled == true;
message = '' message = ''
It is recommended to disable copilot's `suggestion` module, as it can interfere with It is recommended to disable copilot's `suggestion` module, as it can interfere with
completions properly appearing in copilot-cmp. completions properly appearing in copilot-cmp.
''; '';
} }
{ {
when = isEnabled copilot-lua-cfg.panel.enabled; when = copilot-lua-cfg.panel.enabled == true;
message = '' message = ''
It is recommended to disable copilot's `panel` module, as it can interfere with completions It is recommended to disable copilot's `panel` module, as it can interfere with completions
properly appearing in copilot-cmp. properly appearing in copilot-cmp.

View file

@ -471,10 +471,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
extraConfig = cfg: { extraConfig = cfg: {
warnings = lib.nixvim.mkWarnings "plugins.fidget" { warnings = lib.nixvim.mkWarnings "plugins.fidget" {
when = when = (cfg.settings.integration.nvim-tree.enable == true) && !config.plugins.nvim-tree.enable;
(builtins.isBool cfg.settings.integration.nvim-tree.enable)
&& cfg.settings.integration.nvim-tree.enable
&& !config.plugins.nvim-tree.enable;
message = '' message = ''
You have set `plugins.fidget.settings.integrations.nvim-tree.enable` to true but have not enabled `plugins.nvim-tree`. You have set `plugins.fidget.settings.integrations.nvim-tree.enable` to true but have not enabled `plugins.nvim-tree`.

View file

@ -22,8 +22,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
warnings = lib.nixvim.mkWarnings "plugins.flutter-tools" { warnings = lib.nixvim.mkWarnings "plugins.flutter-tools" {
when = when =
(cfg.settings ? debugger.enable) (cfg.settings ? debugger.enable)
&& (lib.isBool cfg.settings.debugger.enable) && (cfg.settings.debugger.enable == true)
&& cfg.settings.debugger.enable
&& (!config.plugins.dap.enable); && (!config.plugins.dap.enable);
message = '' message = ''

View file

@ -104,7 +104,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
extraConfig = cfg: { extraConfig = cfg: {
warnings = lib.nixvim.mkWarnings "plugins.gitsigns" { warnings = lib.nixvim.mkWarnings "plugins.gitsigns" {
when = (lib.isBool cfg.settings.trouble && cfg.settings.trouble) && !config.plugins.trouble.enable; when = (cfg.settings.trouble == true) && !config.plugins.trouble.enable;
message = '' message = ''
You have enabled `plugins.gitsigns.settings.trouble` but `plugins.trouble.enable` is `false`. You have enabled `plugins.gitsigns.settings.trouble` but `plugins.trouble.enable` is `false`.

View file

@ -19,8 +19,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
warnings = lib.nixvim.mkWarnings "plugins.glance" { warnings = lib.nixvim.mkWarnings "plugins.glance" {
when = when =
cfg.settings ? use_trouble_qf cfg.settings ? use_trouble_qf
&& builtins.isBool cfg.settings.use_trouble_qf && (cfg.settings.use_trouble_qf == true)
&& cfg.settings.use_trouble_qf
&& !config.plugins.trouble.enable; && !config.plugins.trouble.enable;
message = '' message = ''

View file

@ -137,24 +137,15 @@ lib.nixvim.plugins.mkNeovimPlugin {
extraConfig = cfg: { extraConfig = cfg: {
warnings = lib.nixvim.mkWarnings "plugins.lazydev" [ warnings = lib.nixvim.mkWarnings "plugins.lazydev" [
{ {
when = when = (cfg.settings.integrations.cmp == true) && !config.plugins.cmp.enable;
builtins.isBool cfg.settings.integrations.cmp
&& !config.plugins.cmp.enable
&& cfg.settings.integrations.cmp;
message = "You have enabled nvim-cmp integration but plugins.cmp is not enabled."; message = "You have enabled nvim-cmp integration but plugins.cmp is not enabled.";
} }
{ {
when = when = (cfg.settings.integrations.lspconfig == true) && !config.plugins.lsp.enable;
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."; message = "You have enabled lspconfig integration but plugins.lsp is not enabled.";
} }
{ {
when = when = (cfg.settings.integrations.coq == true) && !config.plugins.coq-nvim.enable;
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."; message = "You have enabled coq integration but plugins.coq-nvim is not enabled.";
} }
]; ];

View file

@ -236,11 +236,8 @@ in
!( !(
# leanls lsp server is disabled in nvim-lspconfig # leanls lsp server is disabled in nvim-lspconfig
config.plugins.lsp.servers.leanls.enable config.plugins.lsp.servers.leanls.enable
# lsp is not (!) disabled in the lean.nvim plugin # lsp is not explicitly disabled in the lean.nvim plugin
&& !( && (cfg.lsp.enable != false)
# lsp is explicitly set to `false`.
(isBool cfg.lsp.enable) && !cfg.lsp.enable
)
); );
message = '' message = ''
You have not explicitly set `plugins.lean.lsp` to `false` while having `plugins.lsp.servers.leanls.enable` set to `true`. You have not explicitly set `plugins.lean.lsp` to `false` while having `plugins.lsp.servers.leanls.enable` set to `true`.

View file

@ -22,8 +22,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
warnings = lib.nixvim.mkWarnings "plugins.lir" { warnings = lib.nixvim.mkWarnings "plugins.lir" {
when = when =
(cfg.settings ? devicons.enable) (cfg.settings ? devicons.enable)
&& (lib.isBool cfg.settings.devicons.enable) && (cfg.settings.devicons.enable == true)
&& cfg.settings.devicons.enable
&& (!config.plugins.web-devicons.enable); && (!config.plugins.web-devicons.enable);
message = '' message = ''

View file

@ -469,9 +469,7 @@ in
}; };
warnings = lib.nixvim.mkWarnings "plugins.ltex-extra" { warnings = lib.nixvim.mkWarnings "plugins.ltex-extra" {
# https://nvimdev.github.io/lspsaga/implement/#default-options # https://nvimdev.github.io/lspsaga/implement/#default-options
when = when = (cfg.implement.enable == true) && (cfg.symbolInWinbar.enable == false);
(isBool cfg.implement.enable && cfg.implement.enable)
&& (isBool cfg.symbolInWinbar.enable && !cfg.symbolInWinbar.enable);
message = '' message = ''
You have enabled the `implement` module but it requires `symbolInWinbar` to be enabled. You have enabled the `implement` module but it requires `symbolInWinbar` to be enabled.

View file

@ -240,8 +240,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
plugins.sqlite-lua.enable = mkOverride 1490 true; plugins.sqlite-lua.enable = mkOverride 1490 true;
warnings = lib.nixvim.mkWarnings "plugins.neoclip" { warnings = lib.nixvim.mkWarnings "plugins.neoclip" {
when = when =
isBool cfg.settings.enable_persistent_history (cfg.settings.enable_persistent_history == true)
&& cfg.settings.enable_persistent_history
&& options.plugins.sqlite-lua.enable.highestPrio == 1490; && options.plugins.sqlite-lua.enable.highestPrio == 1490;
message = '' message = ''
@ -250,9 +249,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
}; };
assertions = lib.nixvim.mkAssertions "plugins.neoclip" { assertions = lib.nixvim.mkAssertions "plugins.neoclip" {
assertion = assertion = (cfg.settings.enable_persistent_history == true) -> config.plugins.sqlite-lua.enable;
isBool cfg.settings.enable_persistent_history && cfg.settings.enable_persistent_history
-> config.plugins.sqlite-lua.enable;
message = '' message = ''
The persistent history sqlite storage backend needs `sqlite-lua` to function as intended. The persistent history sqlite storage backend needs `sqlite-lua` to function as intended.
You can enable it by setting `plugins.sqlite-lua.enable` to `true`. You can enable it by setting `plugins.sqlite-lua.enable` to `true`.

View file

@ -116,10 +116,11 @@ lib.nixvim.plugins.mkNeovimPlugin {
(name: { (name: {
assertion = assertion =
let let
enabled = cfg.settings.integrations.${name}; extensionEnabled = cfg.settings.integrations.${name} == true;
isEnabled = (isBool enabled) && enabled; pluginEnabled = config.plugins.${name}.enable;
in in
isEnabled -> config.plugins.${name}.enable; extensionEnabled -> pluginEnabled;
message = '' message = ''
You have enabled the `${name}` integration, but `plugins.${name}.enable` is `false`. You have enabled the `${name}` integration, but `plugins.${name}.enable` is `false`.
''; '';

View file

@ -190,7 +190,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
extraConfig = cfg: { extraConfig = cfg: {
warnings = lib.nixvim.mkWarnings "plugins.nvim-autopairs" { warnings = lib.nixvim.mkWarnings "plugins.nvim-autopairs" {
when = (isBool cfg.settings.check_ts) && cfg.settings.check_ts && !config.plugins.treesitter.enable; when = (cfg.settings.check_ts == true) && !config.plugins.treesitter.enable;
message = '' message = ''
You have set `settings.check_ts` to `true` but have not enabled the treesitter plugin. 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

@ -250,11 +250,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
extraConfig = cfg: { extraConfig = cfg: {
warnings = lib.nixvim.mkWarnings "plugins.obsidian" { warnings = lib.nixvim.mkWarnings "plugins.obsidian" {
when = when = (cfg.settings.completion.nvim_cmp == true) && (!config.plugins.cmp.enable);
let
nvimCmpEnabled = isBool cfg.settings.completion.nvim_cmp && cfg.settings.completion.nvim_cmp;
in
nvimCmpEnabled && (!config.plugins.cmp.enable);
message = '' message = ''
You have enabled `completion.nvim_cmp` but `plugins.cmp.enable` is `false`. 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

@ -71,8 +71,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
extraConfig = cfg: { extraConfig = cfg: {
warnings = lib.nixvim.mkWarnings "plugins.twilight" { warnings = lib.nixvim.mkWarnings "plugins.twilight" {
when = when = (cfg.settings.treesitter == true) && (!config.plugins.treesitter.enable);
(isBool cfg.settings.treesitter) && cfg.settings.treesitter && (!config.plugins.treesitter.enable);
message = '' message = ''
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

@ -117,10 +117,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
extraConfig = cfg: { extraConfig = cfg: {
warnings = lib.nixvim.mkWarnings "colorschemes.monokai-pro" { warnings = lib.nixvim.mkWarnings "colorschemes.monokai-pro" {
when = when = (cfg.settings.devicons == true) && (!config.plugins.web-devicons.enable);
(lib.isBool cfg.settings.devicons)
&& cfg.settings.devicons
&& (!config.plugins.web-devicons.enable);
message = '' message = ''
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.

View file

@ -32,6 +32,6 @@ in
''; '';
}; };
extraPackages = lib.optional ((lib.isBool cfg.installGhc) && cfg.installGhc) cfg.ghcPackage; extraPackages = lib.optional (cfg.installGhc == true) cfg.ghcPackage;
}; };
} }

View file

@ -73,11 +73,8 @@ in
]; ];
extraPackages = extraPackages =
let lib.optional (cfg.installCargo == true) cfg.cargoPackage
isEnabled = x: lib.isBool x && x; ++ lib.optional (cfg.installRustc == true) cfg.rustcPackage
in ++ lib.optional (cfg.installRustfmt == true) cfg.rustfmtPackage;
lib.optional (isEnabled cfg.installCargo) cfg.cargoPackage
++ lib.optional (isEnabled cfg.installRustc) cfg.rustcPackage
++ lib.optional (isEnabled cfg.installRustfmt) cfg.rustfmtPackage;
}; };
} }