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

View File

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