Merge remote-tracking branch 'upstream/main' into opmode_retrigger

This commit is contained in:
MurdeRM3L0DY 2023-02-05 21:24:41 +01:00
commit ad3a6b0bcf
13 changed files with 163 additions and 59 deletions

View file

@ -21,12 +21,17 @@ M.defaults = {
log = { "--since=3 days ago" }, -- show commits from the last 3 days
timeout = 120, -- kill processes that take more than 2 minutes
url_format = "https://github.com/%s.git",
-- lazy.nvim requires git >=2.19.0. If you really want to use lazy with an older version,
-- then set the below to false. This is should work, but is NOT supported and will
-- increase downloads a lot.
filter = true,
},
dev = {
-- directory where you store your local plugin projects
path = "~/projects",
---@type string[] plugins that match these patterns will use your local versions instead of being fetched from GitHub
patterns = {}, -- For example {"folke"}
fallback = false, -- Fallback to git when local plugin doesn't exist
},
install = {
-- install missing plugins on startup. This doesn't increase startup time.
@ -114,7 +119,7 @@ M.defaults = {
rtp = {
reset = true, -- reset the runtime path to $VIMRUNTIME and your config directory
---@type string[]
paths = {}, -- add any custom paths here that you want to indluce in the rtp
paths = {}, -- add any custom paths here that you want to includes in the rtp
---@type string[] list any plugins you want to disable here
disabled_plugins = {
-- "gzip",
@ -141,7 +146,7 @@ M.defaults = {
debug = false,
}
M.version = "9.3.1" -- x-release-please-version
M.version = "9.5.0" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")

View file

@ -91,7 +91,10 @@ function Spec:add(plugin, results, is_dep)
end
end
-- dev plugins
if plugin.dev then
if
plugin.dev
and (not Config.options.dev.fallback or vim.fn.isdirectory(Config.options.dev.path .. "/" .. plugin.name) == 1)
then
plugin.dir = Config.options.dev.path .. "/" .. plugin.name
else
-- remote plugin

View file

@ -201,6 +201,22 @@ function M.walk(path, fn)
end)
end
---@param root string
---@param fn fun(modname:string, modpath:string)
---@param modname? string
function M.walkmods(root, fn, modname)
modname = modname and (modname:gsub("%.$", "") .. ".") or ""
M.ls(root, function(path, name, type)
if name == "init.lua" then
fn(modname:gsub("%.$", ""), path)
elseif (type == "file" or type == "link") and name:sub(-4) == ".lua" then
fn(modname .. name:sub(1, -5), path)
elseif type == "directory" then
M.walkmods(path, fn, modname .. name .. ".")
end
end)
end
---@param modname string
---@param fn fun(modname:string, modpath:string)
function M.lsmod(modname, fn)

View file

@ -14,21 +14,27 @@ end
function M.fix_indent(str)
local lines = vim.split(str, "\n")
local first = table.remove(lines, 1)
local width = 120
for _, line in ipairs(lines) do
width = math.min(width, #line:match("^%s*"))
if not line:find("^%s*$") then
width = math.min(width, #line:match("^%s*"))
end
end
for l, line in ipairs(lines) do
lines[l] = line:sub(width + 1)
end
table.insert(lines, 1, first)
return table.concat(lines, "\n")
end
---@alias ReadmeBlock {content:string, lang?:string}
---@param contents table<string, ReadmeBlock|string>
function M.save(contents)
local readme = Util.read_file("README.md")
---@param readme_file? string
function M.save(contents, readme_file)
local readme = Util.read_file(readme_file or "README.md")
for tag, block in pairs(contents) do
if type(block) == "string" then
block = { content = block, lang = "lua" }
@ -48,7 +54,7 @@ function M.save(contents)
end
end
Util.write_file("README.md", readme)
Util.write_file(readme_file or "README.md", readme)
vim.cmd.checktime()
end

View file

@ -5,6 +5,12 @@ local M = {}
function M.check()
vim.health.report_start("lazy.nvim")
if vim.fn.executable("git") == 1 then
vim.health.report_ok("Git installed")
else
vim.health.report_error("Git not installd?")
end
local sites = vim.opt.packpath:get()
local default_site = vim.fn.stdpath("data") .. "/site"
if not vim.tbl_contains(sites, default_site) then
@ -14,7 +20,7 @@ function M.check()
local existing = false
for _, site in pairs(sites) do
for _, packs in ipairs(vim.fn.expand(site .. "/pack/*", false, true)) do
if not packs:find("/dist$") and vim.loop.fs_stat(packs) then
if not packs:find("[/\\]dist$") and vim.loop.fs_stat(packs) then
existing = true
vim.health.report_warn("found existing packages at `" .. packs .. "`")
end

View file

@ -13,7 +13,14 @@ M.reported = {}
function M.start()
M.fast_check()
M.schedule()
if M.schedule() > 0 and not M.has_errors() then
Manage.log({
clear = false,
show = false,
check = true,
concurrency = Config.options.checker.concurrency,
})
end
end
function M.schedule()
@ -21,6 +28,7 @@ function M.schedule()
local next_check = State.checker.last_check + Config.options.checker.frequency - os.time()
next_check = math.max(next_check, 0)
vim.defer_fn(M.check, next_check * 1000)
return next_check
end
---@param opts? {report:boolean} report defaults to true
@ -39,20 +47,23 @@ function M.fast_check(opts)
M.report(opts.report ~= false)
end
function M.has_errors()
for _, plugin in pairs(Config.plugins) do
if Plugin.has_errors(plugin) then
return true
end
end
return false
end
function M.check()
State.checker.last_check = os.time()
State.write() -- update state
local errors = false
for _, plugin in pairs(Config.plugins) do
if Plugin.has_errors(plugin) then
errors = true
break
end
end
if errors then
if M.has_errors() then
M.schedule()
else
Manage.check({
clear = false,
show = false,
concurrency = Config.options.checker.concurrency,
}):wait(function()

View file

@ -136,13 +136,13 @@ function M.check(opts)
}, opts)
end
---@param opts? ManagerOpts
---@param opts? ManagerOpts | {check?:boolean}
function M.log(opts)
opts = M.opts(opts, { mode = "log" })
return M.run({
pipeline = {
{ "git.origin", check = true },
"git.log",
{ "git.log", check = opts.check },
},
plugins = function(plugin)
return plugin.url and plugin._.installed
@ -174,7 +174,10 @@ function M.sync(opts)
end)
opts.show = false
end
local clean = M.clean(opts)
local clean_opts = vim.deepcopy(opts)
clean_opts.plugins = nil
local clean = M.clean(clean_opts)
local install = M.install(opts)
local update = M.update(opts)
clean:wait(function()

View file

@ -68,7 +68,9 @@ function M.spawn(cmd, opts)
for key, value in
pairs(uv.os_environ() --[[@as string[] ]])
do
table.insert(env, key .. "=" .. value)
if key ~= "GIT_DIR" then
table.insert(env, key .. "=" .. value)
end
end
local stdout = uv.new_pipe()

View file

@ -15,7 +15,7 @@ M.log = {
return true
end
local stat = vim.loop.fs_stat(plugin.dir .. "/.git")
return stat and stat.type ~= "directory"
return not (stat and stat.type == "directory")
end,
---@param opts {args?: string[], updated?:boolean, check?:boolean}
run = function(self, opts)
@ -64,10 +64,16 @@ M.clone = {
local args = {
"clone",
self.plugin.url,
"--filter=blob:none",
}
if Config.options.git.filter then
args[#args + 1] = "--filter=blob:none"
end
vim.list_extend(args, {
"--recurse-submodules",
"--progress",
}
})
if self.plugin.branch then
vim.list_extend(args, { "-b", self.plugin.branch })