mirror of https://github.com/folke/lazy.nvim.git
ci(minit): LAZY_STDPATH
This commit is contained in:
parent
cdfea60506
commit
3078688263
|
@ -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,10 +26,11 @@ function M.setup(opts)
|
|||
}, opts)
|
||||
|
||||
-- set stdpaths to use .tests
|
||||
local root = opts.stdpath or ".minit"
|
||||
root = vim.fn.fnamemodify(root, ":p")
|
||||
for _, name in ipairs({ "config", "data", "state", "cache" }) do
|
||||
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
|
||||
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
|
||||
|
@ -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 = {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/env -S nvim -l
|
||||
|
||||
vim.env.LAZY_STDPATH = ".tests"
|
||||
|
||||
vim.opt.rtp:prepend(".")
|
||||
|
||||
-- Setup lazy.nvim
|
||||
|
|
Loading…
Reference in New Issue