Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
makeNixvimWithModule,
pkgs,
lib ? pkgs.lib,
_nixvimTests ? false,
...
}@args:
{
# Add all exported modules here
check = import ../tests/test-derivation.nix { inherit makeNixvimWithModule lib pkgs; };
helpers = import ./helpers.nix (args // { inherit _nixvimTests; });
helpers = import ./helpers.nix { inherit pkgs lib; };
}
7 changes: 4 additions & 3 deletions lib/helpers.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
pkgs,
lib ? pkgs.lib,
_nixvimTests ? false,
...
}:
let
Expand All @@ -24,7 +23,7 @@ let
neovim-plugin = call ./neovim-plugin.nix { };
nixvimTypes = call ./types.nix { };
options = call ./options.nix { };
utils = call ./utils.nix { inherit _nixvimTests; };
utils = call ./utils.nix { };
vim-plugin = call ./vim-plugin.nix { };

# Top-level helper aliases:
Expand Down Expand Up @@ -70,7 +69,6 @@ let
inherit (helpers.utils)
concatNonEmptyLines
emptyTable
enableExceptInTests
groupListBySize
hasContent
ifNonNull'
Expand All @@ -94,6 +92,9 @@ let

toLuaObject = helpers.lua.toLua;
mkLuaInline = helpers.lua.mkInline;

# TODO: Removed 2024-08-20
enableExceptInTests = throw "enableExceptInTests has been removed, please use the `isTest` module option instead.";
};
in
helpers
8 changes: 1 addition & 7 deletions lib/utils.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
lib,
helpers,
_nixvimTests,
}:
{ lib, helpers }:
with lib;
rec {
# Whether a string contains something other than whitespaces
Expand All @@ -16,8 +12,6 @@ rec {
list:
builtins.listToAttrs (lib.lists.imap0 (idx: lib.nameValuePair "__unkeyed-${toString idx}") list);

enableExceptInTests = !_nixvimTests;

emptyTable = {
"__empty" = null;
};
Expand Down
9 changes: 9 additions & 0 deletions modules/misc/context.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,14 @@
internal = true;
visible = false;
};
isTest = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether modules are being evaluated to build a test.
'';
internal = true;
visible = false;
};
};
}
4 changes: 2 additions & 2 deletions tests/enable-except-in-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
}:
let
module =
{ helpers, ... }:
{ config, ... }:
{
plugins.image.enable = helpers.enableExceptInTests;
plugins.image.enable = !config.isTest;
};

inTest = mkTestDerivationFromNixvimModule {
Expand Down
6 changes: 3 additions & 3 deletions tests/test-derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ let
...
}@args:
let
cfg = nvim.config.test;
result = nvim.extend { isTest = true; };
cfg = result.config.test;
runNvim =
lib.warnIf (args ? dontRun)
"mkTestDerivationFromNvim: the `dontRun` argument is deprecated. You should use the `test.runNvim` module option instead."
Expand All @@ -26,7 +27,7 @@ let
inherit name;

nativeBuildInputs = [
nvim
result
pkgs.docker-client
];

Expand Down Expand Up @@ -65,7 +66,6 @@ let
let
nvim = makeNixvimWithModule {
inherit pkgs extraSpecialArgs;
_nixvimTests = true;
module =
if args ? dontRun then
lib.warn
Expand Down
3 changes: 1 addition & 2 deletions wrappers/standalone.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ default_pkgs: self:
pkgs ? default_pkgs,
lib ? pkgs.lib,
extraSpecialArgs ? { },
_nixvimTests ? false,
module,
}:
let
helpers = import ../lib/helpers.nix { inherit pkgs lib _nixvimTests; };
helpers = import ../lib/helpers.nix { inherit pkgs lib; };

inherit (helpers.modules) specialArgsWith;

Expand Down