ci(minit): LAZY_STDPATH

This commit is contained in:
Folke Lemaitre 2024-06-29 08:03:37 +02:00
parent cdfea60506
commit 3078688263
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
2 changed files with 11 additions and 12 deletions

View File

@ -1,22 +1,18 @@
---@diagnostic disable: inject-field
---@class LazyMinit:LazyConfig
---@field stdpath? string
local islist = vim.islist or vim.tbl_islist
---@alias MinitSetup (fun(spec:LazySpec, opts: LazyMinit):LazyMinit?) | (fun(opts: LazyMinit):LazyMinit?) | (fun(spec:LazySpec, opts: LazyMinit):LazyMinit?)
local M = {}
---@param opts LazyMinit
---@param opts LazyConfig
---@return LazySpec[]
local function get_spec(opts)
local ret = opts.spec or {}
return ret and type(ret) == "table" and islist(ret) and ret or { ret }
end
---@param defaults LazyMinit
---@param opts LazyMinit
---@param defaults LazyConfig
---@param opts LazyConfig
function M.extend(defaults, opts)
local spec = {}
vim.list_extend(spec, get_spec(defaults))
@ -30,11 +26,12 @@ function M.setup(opts)
}, opts)
-- set stdpaths to use .tests
local root = opts.stdpath or ".minit"
root = vim.fn.fnamemodify(root, ":p")
if vim.env.LAZY_STDPATH then
local root = vim.fn.fnamemodify(vim.env.LAZY_STDPATH, ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
end
vim.o.loadplugins = true
require("lazy").setup(opts)
@ -68,7 +65,7 @@ function M.repro(opts)
M.setup(opts)
end
---@param opts LazyMinit
---@param opts LazyConfig
function M.busted(opts)
opts = M.extend({
spec = {

View File

@ -1,5 +1,7 @@
#!/usr/bin/env -S nvim -l
vim.env.LAZY_STDPATH = ".tests"
vim.opt.rtp:prepend(".")
-- Setup lazy.nvim