2024-07-07 20:22:39 +03:00
|
|
|
{ pkgs, ... }:
|
2024-07-14 17:46:01 +03:00
|
|
|
let
|
2024-07-19 16:35:17 +03:00
|
|
|
inherit (pkgs) lib;
|
|
|
|
|
2025-04-28 16:59:09 +03:00
|
|
|
# Assertion for a number of plugins of given type defined in nvimPackage.packpathDirs
|
|
|
|
expectNPlugins =
|
|
|
|
config: type: n:
|
|
|
|
let
|
|
|
|
# 'build.extraFiles' must not be combined, so exclude it from counting
|
|
|
|
plugins = builtins.filter (
|
|
|
|
p: p != config.build.extraFiles
|
|
|
|
) config.build.nvimPackage.packpathDirs.myNeovimPackages.${type};
|
|
|
|
numPlugins = builtins.length plugins;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
assertion = numPlugins == n;
|
|
|
|
message = "Expected ${toString n} '${type}' plugins defined in 'nvimPackage.packpathDirs', got ${toString numPlugins}: ${
|
|
|
|
lib.concatMapStringsSep ", " lib.getName plugins
|
|
|
|
}.";
|
|
|
|
};
|
|
|
|
# Assertion that exactly one start plugin is defined in nvimPackage.packpathDirs
|
|
|
|
expectOneStartPlugin = config: expectNPlugins config "start" 1;
|
2025-04-27 17:49:29 +03:00
|
|
|
|
|
|
|
# Stub plugins
|
|
|
|
mkPlugin =
|
|
|
|
name: args:
|
|
|
|
pkgs.vimUtils.buildVimPlugin (
|
|
|
|
{
|
|
|
|
pname = name;
|
|
|
|
version = "2025-04-27";
|
|
|
|
src = pkgs.runCommand "${name}-source" { } ''
|
|
|
|
mkdir "$out"
|
|
|
|
# Add some colliding files
|
|
|
|
echo "# ${name}" > "$out/README.md"
|
|
|
|
echo "Copyright (c) ${name}" > "$out/LICENSE"
|
|
|
|
mkdir "$out/tests"
|
|
|
|
echo "return '${name}'" > "$out/tests/test.lua"
|
|
|
|
# Add import path
|
|
|
|
mkdir -p "$out/lua/${name}"
|
|
|
|
echo "return '${name}'" > "$out/lua/${name}/init.lua"
|
|
|
|
# Add doc
|
|
|
|
mkdir "$out/doc"
|
|
|
|
echo "*${name}.txt* ${name}" > "$out/doc/${name}.txt"
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
// args
|
|
|
|
);
|
|
|
|
# Simple plugins without any features
|
|
|
|
simplePlugin1 = mkPlugin "simple-plugin-1" { };
|
|
|
|
simplePlugin2 = mkPlugin "simple-plugin-2" { };
|
|
|
|
simplePlugin3 = mkPlugin "simple-plugin-3" { };
|
|
|
|
# Plugins with dependencies
|
|
|
|
pluginWithDeps1 = mkPlugin "plugin-with-deps-1" {
|
|
|
|
dependencies = [ simplePlugin1 ];
|
|
|
|
};
|
|
|
|
pluginWithDeps2 = mkPlugin "plugin-with-deps-2" {
|
|
|
|
dependencies = [ simplePlugin2 ];
|
|
|
|
};
|
|
|
|
pluginWithDeps3 = mkPlugin "plugin-with-deps-3" {
|
|
|
|
dependencies = [ simplePlugin3 ];
|
|
|
|
};
|
|
|
|
# Plugin with recursive dependencies
|
|
|
|
pluginWithRecDeps = mkPlugin "plugin-with-rec-deps" {
|
|
|
|
dependencies = [
|
|
|
|
pluginWithDeps1
|
|
|
|
pluginWithDeps2
|
|
|
|
];
|
|
|
|
};
|
|
|
|
# Plugin with non-standard files
|
|
|
|
pluginWithExtraFiles = mkPlugin "plugin-with-extra-files" {
|
|
|
|
postInstall = ''
|
|
|
|
mkdir "$out/_extra"
|
|
|
|
touch "$out/_extra/test"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
# Plugins with Python dependencies
|
|
|
|
pluginWithPyDeps1 = mkPlugin "plugin-with-py-deps-1" {
|
|
|
|
passthru.python3Dependencies = ps: [ ps.pyyaml ];
|
|
|
|
};
|
|
|
|
pluginWithPyDeps2 = mkPlugin "plugin-with-py-deps-2" {
|
|
|
|
passthru.python3Dependencies = ps: [ ps.pyyaml ];
|
|
|
|
};
|
|
|
|
pluginWithPyDeps3 = mkPlugin "plugin-with-py-deps-3" {
|
|
|
|
passthru.python3Dependencies = ps: [ ps.requests ];
|
|
|
|
};
|
2025-04-27 22:13:46 +03:00
|
|
|
# Plugins with Lua dependencies
|
|
|
|
ensureDep =
|
|
|
|
drv: dep:
|
|
|
|
drv.overrideAttrs (prev: {
|
|
|
|
propagatedBuildInputs = lib.unique (
|
|
|
|
prev.propagatedBuildInputs or [ ] ++ [ prev.passthru.lua.pkgs.${dep} ]
|
|
|
|
);
|
|
|
|
});
|
|
|
|
pluginWithLuaDeps1 = ensureDep pkgs.vimPlugins.telescope-nvim "plenary-nvim";
|
|
|
|
pluginWithLuaDeps2 = ensureDep pkgs.vimPlugins.nvim-cmp "plenary-nvim";
|
|
|
|
pluginWithLuaDeps3 = ensureDep pkgs.vimPlugins.gitsigns-nvim "nui-nvim";
|
2024-07-14 17:46:01 +03:00
|
|
|
in
|
2024-07-07 20:22:39 +03:00
|
|
|
{
|
|
|
|
# Test basic functionality
|
2024-08-20 00:54:50 +01:00
|
|
|
default =
|
2024-07-07 20:22:39 +03:00
|
|
|
{ config, ... }:
|
2025-04-27 17:49:29 +03:00
|
|
|
let
|
|
|
|
extraPlugins = [
|
|
|
|
simplePlugin1
|
|
|
|
simplePlugin2
|
|
|
|
simplePlugin3
|
|
|
|
];
|
|
|
|
in
|
2024-07-07 20:22:39 +03:00
|
|
|
{
|
|
|
|
performance.combinePlugins.enable = true;
|
2025-04-27 17:49:29 +03:00
|
|
|
inherit extraPlugins;
|
|
|
|
extraConfigLuaPost = lib.concatMapStringsSep "\n" (
|
|
|
|
name:
|
|
|
|
# lua
|
|
|
|
''
|
|
|
|
-- Plugin is loadable
|
|
|
|
require("${name}")
|
2024-07-07 20:22:39 +03:00
|
|
|
|
2025-04-27 17:49:29 +03:00
|
|
|
-- No separate plugin entry in vim.api.nvim_list_runtime_paths()
|
|
|
|
assert(not vim.iter(vim.api.nvim_list_runtime_paths()):any(function(entry)
|
|
|
|
return entry:find("${name}", 1, true)
|
|
|
|
end), "plugin '${name}' found in runtime, expected to be combined")
|
2024-07-07 20:22:39 +03:00
|
|
|
|
2025-04-27 17:49:29 +03:00
|
|
|
-- Help tags are generated
|
|
|
|
assert(vim.fn.getcompletion("${name}", "help")[1], "no help tags for '${name}'")
|
|
|
|
'') (map lib.getName extraPlugins);
|
2024-07-07 20:22:39 +03:00
|
|
|
assertions = [
|
2025-04-28 16:59:09 +03:00
|
|
|
(expectOneStartPlugin config)
|
2024-07-07 20:22:39 +03:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
# Test disabled option
|
2024-08-20 00:54:50 +01:00
|
|
|
disabled =
|
2024-07-07 20:22:39 +03:00
|
|
|
{ config, ... }:
|
2025-04-27 17:49:29 +03:00
|
|
|
let
|
|
|
|
extraPlugins = [
|
|
|
|
simplePlugin1
|
|
|
|
simplePlugin2
|
|
|
|
simplePlugin3
|
|
|
|
];
|
|
|
|
in
|
2024-07-07 20:22:39 +03:00
|
|
|
{
|
|
|
|
performance.combinePlugins.enable = false;
|
2025-04-27 17:49:29 +03:00
|
|
|
inherit extraPlugins;
|
|
|
|
extraConfigLuaPost = lib.concatMapStringsSep "\n" (
|
|
|
|
name:
|
|
|
|
# lua
|
|
|
|
''
|
|
|
|
-- Separate plugin entry in vim.api.nvim_list_runtime_paths()
|
|
|
|
assert(vim.iter(vim.api.nvim_list_runtime_paths()):any(function(entry)
|
|
|
|
return entry:find("${name}", 1, true)
|
|
|
|
end), "plugin '${name}' isn't found in runtime as a separate entry, expected not to be combined")
|
|
|
|
'') (map lib.getName extraPlugins);
|
2024-07-07 20:22:39 +03:00
|
|
|
assertions = [
|
2025-04-28 16:59:09 +03:00
|
|
|
(expectNPlugins config "start" (builtins.length extraPlugins))
|
2024-07-07 20:22:39 +03:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
# Test that plugin dependencies are handled
|
2024-08-20 00:54:50 +01:00
|
|
|
dependencies =
|
2024-07-07 20:22:39 +03:00
|
|
|
{ config, ... }:
|
|
|
|
{
|
|
|
|
performance.combinePlugins.enable = true;
|
2025-04-27 17:49:29 +03:00
|
|
|
extraPlugins = [
|
|
|
|
# Depends on pluginWithDeps1 and pluginWithDeps2 which themselves depend on simplePlugin1 and simplePlugin2
|
|
|
|
pluginWithRecDeps
|
|
|
|
# Depends on simplePlugin3
|
|
|
|
pluginWithDeps3
|
|
|
|
# Duplicated dependency
|
|
|
|
pluginWithDeps2
|
|
|
|
# Duplicated plugin
|
|
|
|
simplePlugin2
|
2024-07-07 20:22:39 +03:00
|
|
|
];
|
|
|
|
extraConfigLuaPost = ''
|
2025-04-27 17:49:29 +03:00
|
|
|
-- Plugin 'pluginWithRecDeps' and its dependencies are loadable
|
|
|
|
require("plugin-with-rec-deps")
|
|
|
|
require("plugin-with-deps-1")
|
|
|
|
require("plugin-with-deps-2")
|
|
|
|
require("simple-plugin-1")
|
|
|
|
require("simple-plugin-2")
|
|
|
|
-- Plugin 'pluginWithDeps3' and its dependencies are loadable
|
|
|
|
require("plugin-with-deps-3")
|
|
|
|
require("simple-plugin-3")
|
2024-07-07 20:22:39 +03:00
|
|
|
'';
|
|
|
|
assertions = [
|
2025-04-28 16:59:09 +03:00
|
|
|
(expectOneStartPlugin config)
|
2024-07-07 20:22:39 +03:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
# Test that pathsToLink option works
|
2024-08-20 00:54:50 +01:00
|
|
|
paths-to-link =
|
2024-07-07 20:22:39 +03:00
|
|
|
{ config, ... }:
|
|
|
|
{
|
|
|
|
performance.combinePlugins = {
|
|
|
|
enable = true;
|
2025-04-27 17:49:29 +03:00
|
|
|
pathsToLink = [ "/_extra" ];
|
2024-07-07 20:22:39 +03:00
|
|
|
};
|
2025-04-27 17:49:29 +03:00
|
|
|
extraPlugins = [ pluginWithExtraFiles ];
|
2024-07-07 20:22:39 +03:00
|
|
|
extraConfigLuaPost = ''
|
2025-04-27 17:49:29 +03:00
|
|
|
-- Test file is in runtime
|
2024-07-07 20:22:39 +03:00
|
|
|
assert(
|
2025-04-27 17:49:29 +03:00
|
|
|
vim.api.nvim_get_runtime_file("_extra/test", false)[1],
|
|
|
|
"'_extra/test' file isn't found in runtime, expected to be found"
|
2024-07-07 20:22:39 +03:00
|
|
|
)
|
|
|
|
'';
|
|
|
|
assertions = [
|
2025-04-28 16:59:09 +03:00
|
|
|
(expectOneStartPlugin config)
|
2024-07-07 20:22:39 +03:00
|
|
|
];
|
|
|
|
};
|
2024-07-14 11:38:41 +03:00
|
|
|
|
|
|
|
# Test that plugin python3 dependencies are handled
|
2024-08-20 00:54:50 +01:00
|
|
|
python-dependencies =
|
2024-07-14 11:38:41 +03:00
|
|
|
{ config, ... }:
|
|
|
|
{
|
|
|
|
performance.combinePlugins.enable = true;
|
2025-04-27 17:49:29 +03:00
|
|
|
extraPlugins = [
|
2024-07-14 11:38:41 +03:00
|
|
|
# No python3 dependencies
|
2025-04-27 17:49:29 +03:00
|
|
|
simplePlugin1
|
|
|
|
# Duplicated python3-pyyaml dependency
|
|
|
|
pluginWithPyDeps1
|
|
|
|
pluginWithPyDeps2
|
|
|
|
# Python3-requests dependency
|
|
|
|
pluginWithPyDeps3
|
2024-07-14 11:38:41 +03:00
|
|
|
];
|
|
|
|
extraConfigLuaPost = ''
|
|
|
|
-- Python modules are importable
|
|
|
|
vim.cmd.py3("import yaml")
|
|
|
|
vim.cmd.py3("import requests")
|
|
|
|
'';
|
|
|
|
assertions = [
|
2025-04-28 16:59:09 +03:00
|
|
|
(expectOneStartPlugin config)
|
2024-07-14 11:38:41 +03:00
|
|
|
];
|
|
|
|
};
|
2024-07-14 16:10:58 +03:00
|
|
|
|
2025-04-27 22:13:46 +03:00
|
|
|
# Test that plugin lua dependencies are handled
|
|
|
|
lua-dependencies =
|
|
|
|
{ config, ... }:
|
|
|
|
{
|
|
|
|
performance.combinePlugins.enable = true;
|
|
|
|
extraPlugins = [
|
|
|
|
simplePlugin1
|
|
|
|
# Duplicated plenary-nvim dependency
|
|
|
|
pluginWithLuaDeps1
|
|
|
|
pluginWithLuaDeps2
|
|
|
|
# nui-nvim dependency
|
|
|
|
pluginWithLuaDeps3
|
|
|
|
];
|
|
|
|
extraConfigLuaPost = ''
|
|
|
|
-- All packages and its dependencies are importable
|
|
|
|
require("telescope")
|
|
|
|
require("plenary")
|
|
|
|
require("cmp")
|
|
|
|
require("gitsigns")
|
|
|
|
require("nui.popup")
|
|
|
|
'';
|
|
|
|
assertions = [
|
2025-04-28 16:59:09 +03:00
|
|
|
(expectOneStartPlugin config)
|
2025-04-27 22:13:46 +03:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-07-14 16:10:58 +03:00
|
|
|
# Test that optional plugins are handled
|
2024-08-20 00:54:50 +01:00
|
|
|
optional-plugins =
|
2024-07-14 16:10:58 +03:00
|
|
|
{ config, ... }:
|
|
|
|
{
|
|
|
|
performance.combinePlugins.enable = true;
|
2025-04-27 17:49:29 +03:00
|
|
|
extraPlugins = [
|
2024-07-14 16:10:58 +03:00
|
|
|
# Start plugins
|
2025-04-27 17:49:29 +03:00
|
|
|
simplePlugin1
|
|
|
|
simplePlugin2
|
2024-07-14 16:10:58 +03:00
|
|
|
# Optional plugin
|
|
|
|
{
|
2025-04-27 17:49:29 +03:00
|
|
|
plugin = simplePlugin3;
|
2024-07-14 16:10:58 +03:00
|
|
|
optional = true;
|
|
|
|
}
|
2025-04-27 17:49:29 +03:00
|
|
|
# Optional plugin with dependency on simplePlugin1
|
2024-07-14 16:10:58 +03:00
|
|
|
# Dependencies should not be duplicated
|
|
|
|
{
|
2025-04-27 17:49:29 +03:00
|
|
|
plugin = pluginWithDeps1;
|
2024-07-14 16:10:58 +03:00
|
|
|
optional = true;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
extraConfigLuaPost = ''
|
|
|
|
-- Start plugins are loadable
|
2025-04-27 17:49:29 +03:00
|
|
|
require("simple-plugin-1")
|
|
|
|
require("simple-plugin-2")
|
2024-07-14 16:10:58 +03:00
|
|
|
|
|
|
|
-- Opt plugins are not loadable
|
2025-04-27 17:49:29 +03:00
|
|
|
local ok = pcall(require, "simple-plugin-3")
|
|
|
|
assert(not ok, "simplePlugin3 is loadable, expected it to be an opt plugin")
|
|
|
|
ok = pcall(require, "plugin-with-deps-1")
|
|
|
|
assert(not ok, "pluginWithDeps1 is loadable, expected it to be an opt plugin")
|
2024-07-14 16:10:58 +03:00
|
|
|
|
|
|
|
-- Load plugins
|
2025-04-27 17:49:29 +03:00
|
|
|
vim.cmd.packadd("simple-plugin-3")
|
|
|
|
vim.cmd.packadd("plugin-with-deps-1")
|
2024-07-14 16:10:58 +03:00
|
|
|
|
|
|
|
-- Now opt plugins are loadable
|
2025-04-27 17:49:29 +03:00
|
|
|
require("simple-plugin-3")
|
|
|
|
require("plugin-with-deps-1")
|
2024-07-14 16:10:58 +03:00
|
|
|
|
2025-04-27 17:49:29 +03:00
|
|
|
-- Only one copy of simplePlugin1 should be available
|
|
|
|
local num_plugins = #vim.api.nvim_get_runtime_file("lua/simple-plugin-1/init.lua", true)
|
|
|
|
assert(num_plugins == 1, "expected 1 copy of simplePlugin1, got " .. num_plugins)
|
2024-07-14 16:10:58 +03:00
|
|
|
'';
|
2024-07-14 17:46:01 +03:00
|
|
|
assertions = [
|
2025-04-28 16:59:09 +03:00
|
|
|
(expectOneStartPlugin config)
|
|
|
|
# simplePlugin3 pluginWithDeps1
|
|
|
|
(expectNPlugins config "opt" 2)
|
2024-07-14 17:46:01 +03:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
# Test that plugin configs are handled
|
2024-08-20 00:54:50 +01:00
|
|
|
configs =
|
2024-07-14 17:46:01 +03:00
|
|
|
{ config, ... }:
|
|
|
|
{
|
|
|
|
performance.combinePlugins.enable = true;
|
2025-04-27 17:49:29 +03:00
|
|
|
extraPlugins = [
|
2024-07-14 17:46:01 +03:00
|
|
|
# A plugin without config
|
2025-04-27 17:49:29 +03:00
|
|
|
simplePlugin1
|
|
|
|
# Plugin with config
|
2024-07-14 17:46:01 +03:00
|
|
|
{
|
2025-04-27 17:49:29 +03:00
|
|
|
plugin = simplePlugin2;
|
|
|
|
config = "let g:simple_plugin_2 = 1";
|
2024-07-14 17:46:01 +03:00
|
|
|
}
|
|
|
|
# Optional plugin with config
|
|
|
|
{
|
2025-04-27 17:49:29 +03:00
|
|
|
plugin = simplePlugin3;
|
2024-07-14 17:46:01 +03:00
|
|
|
optional = true;
|
2025-04-27 17:49:29 +03:00
|
|
|
config = "let g:simple_plugin_3 = 1";
|
2024-07-14 17:46:01 +03:00
|
|
|
}
|
|
|
|
];
|
|
|
|
extraConfigLuaPost = ''
|
|
|
|
-- Configs are evaluated
|
2025-04-27 17:49:29 +03:00
|
|
|
assert(vim.g.simple_plugin_2 == 1, "simplePlugin2's config isn't evaluated")
|
|
|
|
assert(vim.g.simple_plugin_3 == 1, "simplePlugin3's config isn't evaluated")
|
2024-07-14 17:46:01 +03:00
|
|
|
'';
|
|
|
|
assertions = [
|
2025-04-28 16:59:09 +03:00
|
|
|
(expectOneStartPlugin config)
|
2024-07-19 16:35:17 +03:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-09-24 07:02:22 +01:00
|
|
|
# Test that config.build.extraFiles is not combined
|
2024-08-20 00:54:50 +01:00
|
|
|
files-plugin =
|
2024-07-19 16:35:17 +03:00
|
|
|
{ config, ... }:
|
|
|
|
{
|
|
|
|
performance.combinePlugins.enable = true;
|
2025-04-27 17:49:29 +03:00
|
|
|
extraPlugins = [
|
|
|
|
simplePlugin1
|
|
|
|
simplePlugin2
|
2024-07-19 16:35:17 +03:00
|
|
|
];
|
2025-04-27 17:49:29 +03:00
|
|
|
# Ensure that build.extraFiles is added to extraPlugins
|
2024-07-19 16:35:17 +03:00
|
|
|
wrapRc = true;
|
|
|
|
# Extra user files colliding with plugins
|
|
|
|
extraFiles = {
|
2025-04-27 17:49:29 +03:00
|
|
|
"lua/simple-plugin-1/init.lua".text = "return 1";
|
2024-07-19 16:35:17 +03:00
|
|
|
};
|
|
|
|
# Another form of user files
|
|
|
|
files = {
|
2025-04-27 17:49:29 +03:00
|
|
|
"lua/simple-plugin-2/init.lua" = {
|
|
|
|
extraConfigLua = "return 1";
|
2024-07-19 16:35:17 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
extraConfigLuaPost = ''
|
2025-04-27 17:49:29 +03:00
|
|
|
for _, file in ipairs({"lua/simple-plugin-1/init.lua", "lua/simple-plugin-2/init.lua"}) do
|
|
|
|
local paths_found = vim.api.nvim_get_runtime_file(file, true)
|
|
|
|
local num_found = #paths_found
|
2024-07-19 16:35:17 +03:00
|
|
|
|
2025-04-27 17:49:29 +03:00
|
|
|
-- Both plugin and user version are available
|
|
|
|
assert(num_found == 2, "expected exactly 2 versions of '" .. file .. "', got " .. num_found)
|
2024-07-19 16:35:17 +03:00
|
|
|
|
2025-04-27 17:49:29 +03:00
|
|
|
-- First found file is from build.extraFiles
|
|
|
|
assert(
|
|
|
|
paths_found[1]:find("${lib.getName config.build.extraFiles}", 1, true),
|
|
|
|
"expected first found '" .. file .. "' to be from build.extraFiles, got " .. paths_found[1]
|
|
|
|
)
|
|
|
|
end
|
2024-07-19 16:35:17 +03:00
|
|
|
'';
|
|
|
|
assertions = [
|
2025-04-28 16:59:09 +03:00
|
|
|
(expectOneStartPlugin config)
|
2024-07-14 17:46:01 +03:00
|
|
|
];
|
2024-07-14 16:10:58 +03:00
|
|
|
};
|
2024-07-19 16:31:12 +03:00
|
|
|
|
|
|
|
# Test that standalonePlugins option works
|
2024-08-20 00:54:50 +01:00
|
|
|
standalone-plugins =
|
2024-07-19 16:31:12 +03:00
|
|
|
{ config, ... }:
|
|
|
|
{
|
|
|
|
performance.combinePlugins = {
|
|
|
|
enable = true;
|
2025-04-27 17:49:29 +03:00
|
|
|
standalonePlugins = [
|
2024-07-19 16:31:12 +03:00
|
|
|
# By plugin name
|
2025-04-27 17:49:29 +03:00
|
|
|
"simple-plugin-1"
|
|
|
|
# By package itself. Its dependency, simplePlugin2, not in this list, so will be combined
|
|
|
|
pluginWithDeps2
|
2024-07-19 16:31:12 +03:00
|
|
|
# Dependency of other plugin
|
2025-04-27 17:49:29 +03:00
|
|
|
"simple-plugin-3"
|
2024-07-19 16:31:12 +03:00
|
|
|
];
|
|
|
|
};
|
2025-04-27 17:49:29 +03:00
|
|
|
extraPlugins = [
|
|
|
|
simplePlugin1
|
|
|
|
pluginWithDeps2
|
|
|
|
pluginWithDeps3
|
|
|
|
pluginWithExtraFiles
|
2024-07-19 16:31:12 +03:00
|
|
|
];
|
|
|
|
extraConfigLuaPost = ''
|
2025-04-27 17:49:29 +03:00
|
|
|
local tests = {
|
|
|
|
{"simple-plugin-1", true},
|
|
|
|
{"plugin-with-deps-2", true},
|
|
|
|
{"simple-plugin-2", false},
|
|
|
|
{"plugin-with-deps-3", false},
|
|
|
|
{"simple-plugin-3", true},
|
|
|
|
{"plugin-with-extra-files", false},
|
|
|
|
}
|
|
|
|
for _, test in ipairs(tests) do
|
|
|
|
local name = test[1]
|
|
|
|
local expected_standalone = test[2]
|
2024-07-19 16:31:12 +03:00
|
|
|
|
2025-04-27 17:49:29 +03:00
|
|
|
-- Plugin is loadable
|
|
|
|
require(test[1])
|
2024-07-19 16:31:12 +03:00
|
|
|
|
2025-04-27 17:49:29 +03:00
|
|
|
local paths = vim.api.nvim_get_runtime_file("lua/" .. name, true)
|
|
|
|
-- Plugins shouldn't be duplicated
|
|
|
|
assert(#paths == 1, "expected exactly 1 copy of '" .. name .. "' in runtime, got ", #paths)
|
|
|
|
-- Test if plugin is standalone. This matches directory name before '/lua/'.
|
|
|
|
local is_standalone = paths[1]:match("^(.+)/lua/"):find(name, 1, true) ~= nil
|
|
|
|
local expected_text = expected_standalone and "standalone" or "combined"
|
|
|
|
assert(
|
|
|
|
is_standalone == expected_standalone,
|
|
|
|
"expected '" .. name .. "' to be " .. expected_text .. ", found path: " .. paths[1]
|
|
|
|
)
|
|
|
|
end
|
2024-07-19 16:31:12 +03:00
|
|
|
'';
|
|
|
|
assertions = [
|
2025-04-28 16:59:09 +03:00
|
|
|
# plugin-pack, simplePlugin1, pluginWithDeps2, simplePlugin3
|
|
|
|
(expectNPlugins config "start" 4)
|
2024-07-19 16:31:12 +03:00
|
|
|
];
|
|
|
|
};
|
2024-07-16 14:45:12 +03:00
|
|
|
|
|
|
|
# Test if plenary.filetype is working
|
|
|
|
plenary-nvim = {
|
|
|
|
performance.combinePlugins.enable = true;
|
|
|
|
extraPlugins = [ pkgs.vimPlugins.plenary-nvim ];
|
|
|
|
extraConfigLuaPost = ''
|
|
|
|
-- Plenary filetype detection is usable
|
|
|
|
assert(require("plenary.filetype").detect(".bashrc") == "sh", "plenary.filetype is not working")
|
|
|
|
'';
|
|
|
|
};
|
2024-07-07 20:22:39 +03:00
|
|
|
}
|