Skip to content

Commit

Permalink
feat: added health checks
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 5, 2022
1 parent 8531995 commit dc2dcd2
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@

## ✅ TODO

- [ ] health checks: check merge conflicts async
- [ ] unsupported props or props from other managers
- [ ] other packages still in site?
- [ ] other package manager artifacts still present? compiled etc
- [x] health checks: check merge conflicts async
- [x] unsupported props or props from other managers
- [x] other packages still in site?
- [x] other package manager artifacts still present? compiled etc
- [ ] fix plugin details
- [ ] show disabled plugins (strikethrough?)
- [ ] log file
Expand Down
57 changes: 57 additions & 0 deletions lua/lazy/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
local Util = require("lazy.util")
local Config = require("lazy.core.config")

local M = {}

function M.check()
vim.health.report_start("lazy.nvim")

local existing = false
Util.ls(vim.fn.stdpath("data") .. "/site/pack/", function(path)
existing = true
vim.health.report_warn("found existing packages at `" .. path .. "`")
end)
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

local valid = {
1,
"name",
"uri",
"enabled",
"lazy",
"dev",
"dependencies",
"init",
"config",
"build",
"branch",
"tag",
"commit",
"version",
"pin",
"cmd",
"event",
"keys",
"ft",
"dir",
"_",
}
for _, plugin in pairs(Config.plugins) do
for key in pairs(plugin) do
if not vim.tbl_contains(valid, key) then
vim.health.report_warn("{" .. plugin.name .. "}: unknown key <" .. key .. ">")
end
end
end
end

return M

0 comments on commit dc2dcd2

Please sign in to comment.