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
|
---@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,10 +26,11 @@ 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
|
||||||
|
@ -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 = {
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue