2022-11-28 14:31:13 +08:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
function M.root(root)
|
|
|
|
local f = debug.getinfo(1, "S").source:sub(2)
|
|
|
|
return vim.fn.fnamemodify(f, ":p:h:h") .. "/" .. (root or "")
|
|
|
|
end
|
|
|
|
|
|
|
|
---@param plugin string
|
|
|
|
function M.load(plugin)
|
|
|
|
local name = plugin:match(".*/(.*)")
|
|
|
|
local package_root = M.root(".tests/site/pack/deps/start/")
|
2024-03-22 15:58:36 +08:00
|
|
|
if not vim.uv.fs_stat(package_root .. name) then
|
2022-11-28 14:31:13 +08:00
|
|
|
print("Installing " .. plugin)
|
|
|
|
vim.fn.mkdir(package_root, "p")
|
|
|
|
vim.fn.system({
|
|
|
|
"git",
|
|
|
|
"clone",
|
|
|
|
"--depth=1",
|
|
|
|
"https://github.com/" .. plugin .. ".git",
|
|
|
|
package_root .. "/" .. name,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.setup()
|
|
|
|
vim.cmd([[set runtimepath=$VIMRUNTIME]])
|
|
|
|
vim.opt.runtimepath:append(M.root())
|
|
|
|
vim.opt.packpath = { M.root(".tests/site") }
|
|
|
|
M.load("nvim-lua/plenary.nvim")
|
2022-12-01 23:28:54 +08:00
|
|
|
vim.env.XDG_CONFIG_HOME = M.root(".tests/config")
|
|
|
|
vim.env.XDG_DATA_HOME = M.root(".tests/data")
|
|
|
|
vim.env.XDG_STATE_HOME = M.root(".tests/state")
|
|
|
|
vim.env.XDG_CACHE_HOME = M.root(".tests/cache")
|
2022-11-28 14:31:13 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
M.setup()
|