mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
treewide: use mkAssertions wherever possible
This commit is contained in:
parent
a7e516b322
commit
af6e4b0bad
13 changed files with 63 additions and 72 deletions
|
@ -177,17 +177,17 @@ in
|
|||
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
assertions = [
|
||||
assertions = lib.nixvim.mkAssertions "plugins.alpha" [
|
||||
{
|
||||
assertion = themeDefined || layoutDefined;
|
||||
message = ''
|
||||
Nixvim (plugins.alpha): You have to either set a `theme` or define some sections in `layout`.
|
||||
You have to either set a `theme` or define some sections in `layout`.
|
||||
'';
|
||||
}
|
||||
{
|
||||
assertion = !(themeDefined && layoutDefined);
|
||||
message = ''
|
||||
Nixvim (plugins.alpha): You can't define both a `theme` and custom options.
|
||||
You can't define both a `theme` and custom options.
|
||||
Set `plugins.alpha.theme = null` if you want to configure alpha manually using the `layout` option.
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -86,14 +86,12 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
|
||||
callSetup = false;
|
||||
extraConfig = cfg: {
|
||||
assertions = [
|
||||
{
|
||||
assertion = config.plugins.lsp.enable;
|
||||
message = ''
|
||||
Nixvim (plugins.lsp-status): `plugins.lsp` must be enabled to use lsp-status
|
||||
'';
|
||||
}
|
||||
];
|
||||
assertions = lib.nixvim.mkAssertions "plugins.lsp-status" {
|
||||
assertion = config.plugins.lsp.enable;
|
||||
message = ''
|
||||
`plugins.lsp` must be enabled to use lsp-status
|
||||
'';
|
||||
};
|
||||
|
||||
plugins.lsp = {
|
||||
preConfig = ''
|
||||
|
|
|
@ -152,14 +152,12 @@ in
|
|||
config = mkIf cfg.enable {
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = all (n: elem n (range 0 9)) (attrNames cfg.bookmarks);
|
||||
message = ''
|
||||
Nixvim (plugins.marks): The keys of the `bookmarks` option should be integers between 0 and 9.
|
||||
'';
|
||||
}
|
||||
];
|
||||
assertions = lib.nixvim.mkAssertions "plugins.mark" {
|
||||
assertion = all (n: elem n (range 0 9)) (attrNames cfg.bookmarks);
|
||||
message = ''
|
||||
The keys of the `bookmarks` option should be integers between 0 and 9.
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfigLua =
|
||||
let
|
||||
|
|
|
@ -249,16 +249,14 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
'';
|
||||
};
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion =
|
||||
isBool cfg.settings.enable_persistent_history && cfg.settings.enable_persistent_history
|
||||
-> config.plugins.sqlite-lua.enable;
|
||||
message = ''
|
||||
Nixvim (plugins.neoclip): 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`.
|
||||
'';
|
||||
}
|
||||
];
|
||||
assertions = lib.nixvim.mkAssertions "plugins.neoclip" {
|
||||
assertion =
|
||||
isBool cfg.settings.enable_persistent_history && cfg.settings.enable_persistent_history
|
||||
-> config.plugins.sqlite-lua.enable;
|
||||
message = ''
|
||||
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`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
};
|
||||
|
||||
extraConfig = cfg: {
|
||||
assertions =
|
||||
assertions = lib.nixvim.mkAssertions "plugins.neogit" (
|
||||
map
|
||||
(name: {
|
||||
assertion =
|
||||
|
@ -121,14 +121,15 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
in
|
||||
isEnabled -> config.plugins.${name}.enable;
|
||||
message = ''
|
||||
Nixvim (plugins.neogit): You have enabled the `${name}` integration, but `plugins.${name}.enable` is `false`.
|
||||
You have enabled the `${name}` integration, but `plugins.${name}.enable` is `false`.
|
||||
'';
|
||||
})
|
||||
[
|
||||
"telescope"
|
||||
"diffview"
|
||||
"fzf-lua"
|
||||
];
|
||||
]
|
||||
);
|
||||
|
||||
extraPackages =
|
||||
[
|
||||
|
|
|
@ -119,7 +119,7 @@ in
|
|||
} // cfg.extraOptions;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
assertions = [
|
||||
assertions = lib.nixvim.mkAssertions "plugins.nvim-jdtls" [
|
||||
{
|
||||
assertion = cfg.cmd != null || cfg.data != null;
|
||||
message = "You have to either set the `plugins.nvim-jdtls.data` or the `plugins.nvim-jdtls.cmd` option.";
|
||||
|
@ -127,7 +127,7 @@ in
|
|||
{
|
||||
assertion = cfg.cmd == null -> cfg.jdtLanguageServerPackage != null;
|
||||
message = ''
|
||||
Nixvim (plugins.nvim-jdtls) You haven't defined a `cmd` or `jdtLanguageServerPackage`.
|
||||
You haven't defined a `cmd` or `jdtLanguageServerPackage`.
|
||||
|
||||
The default `cmd` requires `plugins.nvim-jdtls.jdtLanguageServerPackage` to be set.
|
||||
'';
|
||||
|
|
|
@ -108,14 +108,12 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
};
|
||||
|
||||
extraConfig = cfg: {
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
|
||||
message = ''
|
||||
Nixvim (plugins.package-info): The telescope integration needs telescope to function as intended.
|
||||
'';
|
||||
}
|
||||
];
|
||||
assertions = lib.nixvim.mkAssertions "plugins.package-info" {
|
||||
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
|
||||
message = ''
|
||||
The telescope integration needs telescope to function as intended.
|
||||
'';
|
||||
};
|
||||
|
||||
extraPackages = [ cfg.packageManagerPackage ];
|
||||
|
||||
|
|
|
@ -226,17 +226,17 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
callSetup = false;
|
||||
|
||||
extraConfig = cfg: {
|
||||
assertions = [
|
||||
assertions = lib.nixvim.mkAssertions "plugins.rest" [
|
||||
{
|
||||
assertion = config.plugins.treesitter.enable;
|
||||
message = ''
|
||||
Nixvim (plugins.rest): Requires the `http` parser from `plugins.treesitter`, please set `plugins.treesitter.enable`.
|
||||
Requires the `http` parser from `plugins.treesitter`, please set `plugins.treesitter.enable`.
|
||||
'';
|
||||
}
|
||||
{
|
||||
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
|
||||
message = ''
|
||||
Nixvim (plugins.rest): You have `plugins.rest.enableTelescope` set to true, but `plugins.telescope.enable` is false.
|
||||
You have `plugins.rest.enableTelescope` set to true, but `plugins.telescope.enable` is false.
|
||||
Either disable the telescope integration or enable telescope.
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -57,15 +57,13 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
|
||||
globals.rustaceanvim = cfg.settings;
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.enable -> !config.plugins.lsp.servers.rust_analyzer.enable;
|
||||
message = ''
|
||||
Nixvim (plugins.rustaceanvim): Both `plugins.rustaceanvim.enable` and `plugins.lsp.servers.rust_analyzer.enable` are true.
|
||||
Disable one of them otherwise you will have multiple clients attached to each buffer.
|
||||
'';
|
||||
}
|
||||
];
|
||||
assertions = lib.nixvim.mkAssertions "plugins.rustaceanvim" {
|
||||
assertion = cfg.enable -> !config.plugins.lsp.servers.rust_analyzer.enable;
|
||||
message = ''
|
||||
Both `plugins.rustaceanvim.enable` and `plugins.lsp.servers.rust_analyzer.enable` are true.
|
||||
Disable one of them otherwise you will have multiple clients attached to each buffer.
|
||||
'';
|
||||
};
|
||||
|
||||
# TODO: remove after 24.11
|
||||
warnings = lib.nixvim.mkWarnings "plugins.rustaceanvim" {
|
||||
|
|
|
@ -267,11 +267,11 @@ in
|
|||
sectionNames = attrNames cfg.sections;
|
||||
numSections = length sectionNames;
|
||||
in
|
||||
[
|
||||
lib.nixvim.mkAssertions "plugins.startup" [
|
||||
{
|
||||
assertion = (cfg.options.paddings == null) || (length cfg.options.paddings) == numSections;
|
||||
message = ''
|
||||
Nixvim (plugins.startup): Make sure that `plugins.startup.options.paddings` has the same
|
||||
Make sure that `plugins.startup.options.paddings` has the same
|
||||
number of elements as there are sections.
|
||||
'';
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ in
|
|||
assertion =
|
||||
((length cfg.parts) <= numSections) && (all (part: hasAttr part cfg.sections) cfg.parts);
|
||||
message = ''
|
||||
Nixvim (plugins.startup): You should not have more section names in `plugins.startup.parts` than you have sections defined.
|
||||
You should not have more section names in `plugins.startup.parts` than you have sections defined.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
|
|
@ -24,14 +24,13 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
# TODO: Remove once nixpkgs #349346 lands, since it will have telescope-nvim
|
||||
# as a dependency.
|
||||
extraConfig = cfg: {
|
||||
assertions = [
|
||||
{
|
||||
assertion = config.plugins.telescope.enable;
|
||||
message = ''
|
||||
Nixvim (plugins.telekasten): The plugin needs telescope to function as intended.
|
||||
'';
|
||||
}
|
||||
];
|
||||
assertions = lib.nixvim.mkAssertions "plugins.telekasten" {
|
||||
assertion = config.plugins.telescope.enable;
|
||||
message = ''
|
||||
Nixvim (plugins.telekasten): The plugin needs telescope to function as intended.
|
||||
'';
|
||||
};
|
||||
|
||||
extraPlugins = [ cfg.plenaryPackage ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -359,17 +359,17 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
'';
|
||||
};
|
||||
|
||||
assertions = [
|
||||
assertions = lib.nixvim.mkAssertions "plugins.yanky" [
|
||||
{
|
||||
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
|
||||
message = ''
|
||||
Nixvim (plugins.yanky): The telescope integration needs telescope to function as intended
|
||||
The telescope integration needs telescope to function as intended
|
||||
'';
|
||||
}
|
||||
{
|
||||
assertion = cfg.settings.ring.storage == "sqlite" -> config.plugins.sqlite-lua.enable;
|
||||
message = ''
|
||||
Nixvim (plugins.yanky): The sqlite storage backend needs `sqlite-lua` to function as intended.
|
||||
The sqlite storage backend needs `sqlite-lua` to function as intended.
|
||||
You can enable it by setting `plugins.sqlite-lua.enable` to `true`.
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
settingsExample = { };
|
||||
|
||||
extraConfig = cfg: {
|
||||
assertions =
|
||||
assertions = lib.nixvim.mkAssertions "colorschemes.palette" (
|
||||
lib.mapAttrsToList
|
||||
(
|
||||
name: defaultPaletteNames:
|
||||
|
@ -131,7 +131,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
{
|
||||
assertion = lib.isString palette -> lib.elem palette allowedPaletteNames;
|
||||
message = ''
|
||||
Nixvim (colorschemes.palette): `settings.palettes.${name}` (${palette}") is not part of the allowed ${name} palette names (${lib.concatStringsSep " " allowedPaletteNames}).
|
||||
`settings.palettes.${name}` (${palette}") is not part of the allowed ${name} palette names (${lib.concatStringsSep " " allowedPaletteNames}).
|
||||
'';
|
||||
}
|
||||
)
|
||||
|
@ -150,6 +150,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
"dark"
|
||||
"bright"
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue