mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +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 ];
|
extraPlugins = [ cfg.package ];
|
||||||
|
|
||||||
assertions = [
|
assertions = lib.nixvim.mkAssertions "plugins.alpha" [
|
||||||
{
|
{
|
||||||
assertion = themeDefined || layoutDefined;
|
assertion = themeDefined || layoutDefined;
|
||||||
message = ''
|
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);
|
assertion = !(themeDefined && layoutDefined);
|
||||||
message = ''
|
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.
|
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;
|
callSetup = false;
|
||||||
extraConfig = cfg: {
|
extraConfig = cfg: {
|
||||||
assertions = [
|
assertions = lib.nixvim.mkAssertions "plugins.lsp-status" {
|
||||||
{
|
assertion = config.plugins.lsp.enable;
|
||||||
assertion = config.plugins.lsp.enable;
|
message = ''
|
||||||
message = ''
|
`plugins.lsp` must be enabled to use lsp-status
|
||||||
Nixvim (plugins.lsp-status): `plugins.lsp` must be enabled to use lsp-status
|
'';
|
||||||
'';
|
};
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
plugins.lsp = {
|
plugins.lsp = {
|
||||||
preConfig = ''
|
preConfig = ''
|
||||||
|
|
|
@ -152,14 +152,12 @@ in
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
extraPlugins = [ cfg.package ];
|
extraPlugins = [ cfg.package ];
|
||||||
|
|
||||||
assertions = [
|
assertions = lib.nixvim.mkAssertions "plugins.mark" {
|
||||||
{
|
assertion = all (n: elem n (range 0 9)) (attrNames cfg.bookmarks);
|
||||||
assertion = all (n: elem n (range 0 9)) (attrNames cfg.bookmarks);
|
message = ''
|
||||||
message = ''
|
The keys of the `bookmarks` option should be integers between 0 and 9.
|
||||||
Nixvim (plugins.marks): The keys of the `bookmarks` option should be integers between 0 and 9.
|
'';
|
||||||
'';
|
};
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
extraConfigLua =
|
extraConfigLua =
|
||||||
let
|
let
|
||||||
|
|
|
@ -249,16 +249,14 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
assertions = [
|
assertions = lib.nixvim.mkAssertions "plugins.neoclip" {
|
||||||
{
|
assertion =
|
||||||
assertion =
|
isBool cfg.settings.enable_persistent_history && cfg.settings.enable_persistent_history
|
||||||
isBool cfg.settings.enable_persistent_history && cfg.settings.enable_persistent_history
|
-> config.plugins.sqlite-lua.enable;
|
||||||
-> config.plugins.sqlite-lua.enable;
|
message = ''
|
||||||
message = ''
|
The persistent history sqlite storage backend needs `sqlite-lua` to function as intended.
|
||||||
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`.
|
||||||
You can enable it by setting `plugins.sqlite-lua.enable` to `true`.
|
'';
|
||||||
'';
|
};
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = cfg: {
|
extraConfig = cfg: {
|
||||||
assertions =
|
assertions = lib.nixvim.mkAssertions "plugins.neogit" (
|
||||||
map
|
map
|
||||||
(name: {
|
(name: {
|
||||||
assertion =
|
assertion =
|
||||||
|
@ -121,14 +121,15 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
in
|
in
|
||||||
isEnabled -> config.plugins.${name}.enable;
|
isEnabled -> config.plugins.${name}.enable;
|
||||||
message = ''
|
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"
|
"telescope"
|
||||||
"diffview"
|
"diffview"
|
||||||
"fzf-lua"
|
"fzf-lua"
|
||||||
];
|
]
|
||||||
|
);
|
||||||
|
|
||||||
extraPackages =
|
extraPackages =
|
||||||
[
|
[
|
||||||
|
|
|
@ -119,7 +119,7 @@ in
|
||||||
} // cfg.extraOptions;
|
} // cfg.extraOptions;
|
||||||
in
|
in
|
||||||
mkIf cfg.enable {
|
mkIf cfg.enable {
|
||||||
assertions = [
|
assertions = lib.nixvim.mkAssertions "plugins.nvim-jdtls" [
|
||||||
{
|
{
|
||||||
assertion = cfg.cmd != null || cfg.data != null;
|
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.";
|
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;
|
assertion = cfg.cmd == null -> cfg.jdtLanguageServerPackage != null;
|
||||||
message = ''
|
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.
|
The default `cmd` requires `plugins.nvim-jdtls.jdtLanguageServerPackage` to be set.
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -108,14 +108,12 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = cfg: {
|
extraConfig = cfg: {
|
||||||
assertions = [
|
assertions = lib.nixvim.mkAssertions "plugins.package-info" {
|
||||||
{
|
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
|
||||||
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
|
message = ''
|
||||||
message = ''
|
The telescope integration needs telescope to function as intended.
|
||||||
Nixvim (plugins.package-info): The telescope integration needs telescope to function as intended.
|
'';
|
||||||
'';
|
};
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
extraPackages = [ cfg.packageManagerPackage ];
|
extraPackages = [ cfg.packageManagerPackage ];
|
||||||
|
|
||||||
|
|
|
@ -226,17 +226,17 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
callSetup = false;
|
callSetup = false;
|
||||||
|
|
||||||
extraConfig = cfg: {
|
extraConfig = cfg: {
|
||||||
assertions = [
|
assertions = lib.nixvim.mkAssertions "plugins.rest" [
|
||||||
{
|
{
|
||||||
assertion = config.plugins.treesitter.enable;
|
assertion = config.plugins.treesitter.enable;
|
||||||
message = ''
|
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;
|
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
|
||||||
message = ''
|
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.
|
Either disable the telescope integration or enable telescope.
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,15 +57,13 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
|
|
||||||
globals.rustaceanvim = cfg.settings;
|
globals.rustaceanvim = cfg.settings;
|
||||||
|
|
||||||
assertions = [
|
assertions = lib.nixvim.mkAssertions "plugins.rustaceanvim" {
|
||||||
{
|
assertion = cfg.enable -> !config.plugins.lsp.servers.rust_analyzer.enable;
|
||||||
assertion = cfg.enable -> !config.plugins.lsp.servers.rust_analyzer.enable;
|
message = ''
|
||||||
message = ''
|
Both `plugins.rustaceanvim.enable` and `plugins.lsp.servers.rust_analyzer.enable` are true.
|
||||||
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.
|
||||||
Disable one of them otherwise you will have multiple clients attached to each buffer.
|
'';
|
||||||
'';
|
};
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
# TODO: remove after 24.11
|
# TODO: remove after 24.11
|
||||||
warnings = lib.nixvim.mkWarnings "plugins.rustaceanvim" {
|
warnings = lib.nixvim.mkWarnings "plugins.rustaceanvim" {
|
||||||
|
|
|
@ -267,11 +267,11 @@ in
|
||||||
sectionNames = attrNames cfg.sections;
|
sectionNames = attrNames cfg.sections;
|
||||||
numSections = length sectionNames;
|
numSections = length sectionNames;
|
||||||
in
|
in
|
||||||
[
|
lib.nixvim.mkAssertions "plugins.startup" [
|
||||||
{
|
{
|
||||||
assertion = (cfg.options.paddings == null) || (length cfg.options.paddings) == numSections;
|
assertion = (cfg.options.paddings == null) || (length cfg.options.paddings) == numSections;
|
||||||
message = ''
|
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.
|
number of elements as there are sections.
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ in
|
||||||
assertion =
|
assertion =
|
||||||
((length cfg.parts) <= numSections) && (all (part: hasAttr part cfg.sections) cfg.parts);
|
((length cfg.parts) <= numSections) && (all (part: hasAttr part cfg.sections) cfg.parts);
|
||||||
message = ''
|
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
|
# TODO: Remove once nixpkgs #349346 lands, since it will have telescope-nvim
|
||||||
# as a dependency.
|
# as a dependency.
|
||||||
extraConfig = cfg: {
|
extraConfig = cfg: {
|
||||||
assertions = [
|
assertions = lib.nixvim.mkAssertions "plugins.telekasten" {
|
||||||
{
|
assertion = config.plugins.telescope.enable;
|
||||||
assertion = config.plugins.telescope.enable;
|
message = ''
|
||||||
message = ''
|
Nixvim (plugins.telekasten): The plugin needs telescope to function as intended.
|
||||||
Nixvim (plugins.telekasten): The plugin needs telescope to function as intended.
|
'';
|
||||||
'';
|
};
|
||||||
}
|
|
||||||
];
|
|
||||||
extraPlugins = [ cfg.plenaryPackage ];
|
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;
|
assertion = cfg.enableTelescope -> config.plugins.telescope.enable;
|
||||||
message = ''
|
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;
|
assertion = cfg.settings.ring.storage == "sqlite" -> config.plugins.sqlite-lua.enable;
|
||||||
message = ''
|
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`.
|
You can enable it by setting `plugins.sqlite-lua.enable` to `true`.
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
settingsExample = { };
|
settingsExample = { };
|
||||||
|
|
||||||
extraConfig = cfg: {
|
extraConfig = cfg: {
|
||||||
assertions =
|
assertions = lib.nixvim.mkAssertions "colorschemes.palette" (
|
||||||
lib.mapAttrsToList
|
lib.mapAttrsToList
|
||||||
(
|
(
|
||||||
name: defaultPaletteNames:
|
name: defaultPaletteNames:
|
||||||
|
@ -131,7 +131,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
{
|
{
|
||||||
assertion = lib.isString palette -> lib.elem palette allowedPaletteNames;
|
assertion = lib.isString palette -> lib.elem palette allowedPaletteNames;
|
||||||
message = ''
|
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"
|
"dark"
|
||||||
"bright"
|
"bright"
|
||||||
];
|
];
|
||||||
};
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue