2022-12-06 04:31:26 +08:00
|
|
|
local Config = require("lazy.core.config")
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
function M.check()
|
|
|
|
vim.health.report_start("lazy.nvim")
|
|
|
|
|
2023-01-24 15:48:14 +08:00
|
|
|
if vim.fn.executable("git") == 1 then
|
|
|
|
vim.health.report_ok("Git installed")
|
|
|
|
else
|
|
|
|
vim.health.report_error("Git not installd?")
|
|
|
|
end
|
|
|
|
|
2023-01-04 06:48:00 +08:00
|
|
|
local sites = vim.opt.packpath:get()
|
|
|
|
local default_site = vim.fn.stdpath("data") .. "/site"
|
|
|
|
if not vim.tbl_contains(sites, default_site) then
|
|
|
|
sites[#sites + 1] = default_site
|
|
|
|
end
|
|
|
|
|
2022-12-06 04:31:26 +08:00
|
|
|
local existing = false
|
2023-01-04 06:48:00 +08:00
|
|
|
for _, site in pairs(sites) do
|
|
|
|
for _, packs in ipairs(vim.fn.expand(site .. "/pack/*", false, true)) do
|
2023-02-01 15:08:44 +08:00
|
|
|
if not packs:find("[/\\]dist$") and vim.loop.fs_stat(packs) then
|
2023-01-04 06:48:00 +08:00
|
|
|
existing = true
|
|
|
|
vim.health.report_warn("found existing packages at `" .. packs .. "`")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-12-06 04:31:26 +08:00
|
|
|
if not existing then
|
|
|
|
vim.health.report_ok("no existing packages found by other package managers")
|
|
|
|
end
|
|
|
|
|
|
|
|
local packer_compiled = vim.fn.stdpath("config") .. "/plugin/packer_compiled.lua"
|
|
|
|
if vim.loop.fs_stat(packer_compiled) then
|
|
|
|
vim.health.report_error("please remove the file `" .. packer_compiled .. "`")
|
|
|
|
else
|
|
|
|
vim.health.report_ok("packer_compiled.lua not found")
|
|
|
|
end
|
|
|
|
|
2023-01-02 16:44:09 +08:00
|
|
|
local spec = Config.spec
|
2022-12-30 18:52:09 +08:00
|
|
|
for _, plugin in pairs(spec.plugins) do
|
2023-01-04 16:35:00 +08:00
|
|
|
M.check_valid(plugin)
|
|
|
|
M.check_override(plugin)
|
2022-12-06 04:31:26 +08:00
|
|
|
end
|
2023-01-02 16:44:09 +08:00
|
|
|
if #spec.notifs > 0 then
|
|
|
|
vim.health.report_error("Issues were reported when loading your specs:")
|
|
|
|
for _, notif in ipairs(spec.notifs) do
|
|
|
|
local lines = vim.split(notif.msg, "\n")
|
2022-12-30 18:52:09 +08:00
|
|
|
for _, line in ipairs(lines) do
|
2023-01-02 16:44:09 +08:00
|
|
|
if notif.level == vim.log.levels.ERROR then
|
|
|
|
vim.health.report_error(line)
|
|
|
|
else
|
|
|
|
vim.health.report_warn(line)
|
|
|
|
end
|
2022-12-30 18:52:09 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-12-06 04:31:26 +08:00
|
|
|
end
|
|
|
|
|
2023-01-04 16:35:00 +08:00
|
|
|
---@param plugin LazyPlugin
|
|
|
|
function M.check_valid(plugin)
|
|
|
|
for key in pairs(plugin) do
|
|
|
|
if not vim.tbl_contains(M.valid, key) then
|
|
|
|
if key ~= "module" or type(plugin.module) ~= "boolean" then
|
|
|
|
vim.health.report_warn("{" .. plugin.name .. "}: unknown key <" .. key .. ">")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
---@param plugin LazyPlugin
|
|
|
|
function M.check_override(plugin)
|
|
|
|
if not plugin._.super then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2023-01-08 22:01:49 +08:00
|
|
|
local Handler = require("lazy.core.handler")
|
|
|
|
local skip = { "dependencies", "_", "opts" }
|
|
|
|
vim.list_extend(skip, vim.tbl_values(Handler.types))
|
|
|
|
|
2023-01-04 16:35:00 +08:00
|
|
|
for key, value in pairs(plugin._.super) do
|
2023-01-08 22:01:49 +08:00
|
|
|
if not vim.tbl_contains(skip, key) and plugin[key] and plugin[key] ~= value then
|
2023-01-04 16:35:00 +08:00
|
|
|
vim.health.report_warn("{" .. plugin.name .. "}: overriding <" .. key .. ">")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
M.valid = {
|
|
|
|
1,
|
2023-01-08 22:01:49 +08:00
|
|
|
"_",
|
2023-01-04 16:35:00 +08:00
|
|
|
"branch",
|
2023-01-08 22:01:49 +08:00
|
|
|
"build",
|
2023-01-04 16:35:00 +08:00
|
|
|
"cmd",
|
2023-01-08 22:01:49 +08:00
|
|
|
"commit",
|
|
|
|
"cond",
|
|
|
|
"config",
|
|
|
|
"dependencies",
|
|
|
|
"dev",
|
|
|
|
"dir",
|
|
|
|
"enabled",
|
2023-01-04 16:35:00 +08:00
|
|
|
"event",
|
|
|
|
"ft",
|
2023-01-08 22:01:49 +08:00
|
|
|
"import",
|
|
|
|
"init",
|
|
|
|
"keys",
|
|
|
|
"lazy",
|
|
|
|
"module",
|
|
|
|
"name",
|
|
|
|
"opts",
|
|
|
|
"pin",
|
2023-01-04 16:35:00 +08:00
|
|
|
"priority",
|
2023-01-08 22:01:49 +08:00
|
|
|
"tag",
|
|
|
|
"url",
|
|
|
|
"version",
|
2023-01-04 16:35:00 +08:00
|
|
|
}
|
|
|
|
|
2022-12-06 04:31:26 +08:00
|
|
|
return M
|