2024-07-06 18:36:00 +03:00
|
|
|
{
|
|
|
|
extraLuaPackages = {
|
|
|
|
extraLuaPackages = ps: [ ps.jsregexp ];
|
|
|
|
# Make sure jsregexp is in LUA_PATH
|
|
|
|
extraConfigLua = ''require("jsregexp")'';
|
|
|
|
};
|
2024-07-21 11:55:52 +03:00
|
|
|
|
|
|
|
# Test that all extraConfigs are present in output
|
2024-08-20 00:54:50 +01:00
|
|
|
all-configs =
|
2024-07-21 11:55:52 +03:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
configs = {
|
|
|
|
extraConfigLuaPre = "string.format('extraConfigLuaPre1')";
|
|
|
|
extraConfigLua = "string.format('extraConfigLua2')";
|
|
|
|
extraConfigLuaPost = "string.format('extraConfigLuaPost3')";
|
|
|
|
extraConfigVim = "let g:var = 'extraConfigVim4'";
|
|
|
|
};
|
|
|
|
mkConfigAssertions = name: value: [
|
|
|
|
{
|
|
|
|
assertion = lib.hasInfix "extraConfigLuaPre1" value;
|
2024-08-04 00:03:45 +01:00
|
|
|
message = "Configuration file ${name} should contain extraConfigLuaPre.";
|
2024-07-21 11:55:52 +03:00
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion = lib.hasInfix "extraConfigLua2" value;
|
2024-08-04 00:03:45 +01:00
|
|
|
message = "Configuration file ${name} should contain extraConfigLua.";
|
2024-07-21 11:55:52 +03:00
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion = lib.hasInfix "extraConfigLuaPost3" value;
|
2024-08-04 00:03:45 +01:00
|
|
|
message = "Configuration file ${name} should contain extraConfigLuaPost.";
|
2024-07-21 11:55:52 +03:00
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion = lib.hasInfix "extraConfigVim4" value;
|
2024-08-04 00:03:45 +01:00
|
|
|
message = "Configuration file ${name} should contain extraConfigVim.";
|
2024-07-21 11:55:52 +03:00
|
|
|
}
|
|
|
|
];
|
|
|
|
in
|
|
|
|
configs
|
|
|
|
// {
|
|
|
|
files = {
|
|
|
|
"test.lua" = configs;
|
|
|
|
"test.vim" = configs;
|
|
|
|
};
|
|
|
|
|
|
|
|
extraPlugins = [
|
|
|
|
{
|
2024-10-13 09:54:05 +03:00
|
|
|
config = "let g:var = 'wrappedNeovim.initRc5'";
|
2024-10-13 09:28:12 +03:00
|
|
|
|
|
|
|
# Test that final init.lua contains all config sections
|
|
|
|
plugin = pkgs.runCommandLocal "init-lua-content-test" { } ''
|
|
|
|
test_content() {
|
|
|
|
if ! grep -qF "$1" "${config.build.initFile}"; then
|
|
|
|
echo "init.lua should contain $2" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
test_content extraConfigLuaPre1 extraConfigLuaPre
|
|
|
|
test_content extraConfigLua2 extraConfigLua
|
|
|
|
test_content extraConfigLuaPost3 extraConfigLuaPost
|
|
|
|
test_content extraConfigVim4 extraConfigVim4
|
2024-10-13 09:54:05 +03:00
|
|
|
test_content wrappedNeovim.initRc5 wrappedNeovim.initRc
|
2024-10-13 09:28:12 +03:00
|
|
|
|
|
|
|
touch $out
|
|
|
|
'';
|
2024-07-21 11:55:52 +03:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
assertions =
|
2024-08-04 00:03:45 +01:00
|
|
|
# Main init.lua
|
2024-07-21 11:55:52 +03:00
|
|
|
mkConfigAssertions "init.lua" config.content
|
2024-08-04 00:03:45 +01:00
|
|
|
# Extra file modules
|
2024-07-21 11:55:52 +03:00
|
|
|
++ mkConfigAssertions "test.lua" config.files."test.lua".content
|
2024-08-04 00:03:45 +01:00
|
|
|
++ mkConfigAssertions "test.vim" config.files."test.vim".content;
|
2024-07-21 11:55:52 +03:00
|
|
|
};
|
|
|
|
|
2024-08-20 00:54:50 +01:00
|
|
|
files-default-empty =
|
2024-07-21 11:55:52 +03:00
|
|
|
{ config, helpers, ... }:
|
|
|
|
{
|
|
|
|
files = {
|
|
|
|
# lua type
|
|
|
|
"test.lua" = { };
|
|
|
|
# vim type
|
|
|
|
"test.vim" = { };
|
|
|
|
};
|
|
|
|
|
|
|
|
assertions = [
|
|
|
|
{
|
|
|
|
assertion = !helpers.hasContent config.files."test.lua".content;
|
|
|
|
message = "Default content of test.lua file is expected to be empty.";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion = !helpers.hasContent config.files."test.vim".content;
|
|
|
|
message = "Default content of test.vim file is expected to be empty.";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2024-07-06 18:36:00 +03:00
|
|
|
}
|