Browse Source

Add health check provider

master
Adam Pippin 2 years ago
parent
commit
d21a20d269
  1. 3
      autoload/health/nukevim.vim
  2. 14
      lua/module.lua
  3. 22
      lua/module/plugins.lua
  4. 4
      lua/module/start.lua
  5. 21
      lua/nukevim.lua

3
autoload/health/nukevim.vim

@ -0,0 +1,3 @@
function! health#nukevim#check()
lua require 'nukevim'.health(nukevim)
endfunction

14
lua/module.lua

@ -44,4 +44,18 @@ end
function Module:install()
end
-- For running health check
-- This should return a table that looks something like:
-- {
-- messages = {
-- {"ok", "This is a message"},
-- {"info", "This is a message"},
-- {"warn", "This is a message"},
-- {"error", "This is a message"},
-- }
-- }
function Module:health()
return nil
end
return Module

22
lua/module/plugins.lua

@ -85,4 +85,26 @@ function M:cleanup()
package_manager:cleanup()
end
function M:health()
messages = {}
for idx, plugin in pairs(self.config.plugins) do
if (plugin.enable ~= nil and plugin.enable == false) then
table.insert(messages, { "info", ('%s: disabled by config'):format(plugin.name) });
else
if (plugin.requires ~= nil) then
for i=1,#plugin.requires do
if (not has_command(plugin.requires[i])) then
table.insert(messages, { "warn", ('%s: missing dependency %s'):format(plugin.name, plugin.requires[i]) })
end
end
end
end
end
return {
messages = messages
}
end
return M

4
lua/module/start.lua

@ -1,5 +1,9 @@
local M = require('module'):new()
-- TODO: When enabled, and when in neovim-qt, this seems to overwrite :checkhealth.
-- Maybe track if it's been triggered _at all_ this session, and if so don't trigger
-- again.
function M:boot()
self.opts = {
win = {

21
lua/nukevim.lua

@ -52,4 +52,25 @@ function NukeVim:help()
vim.cmd(':h nukevim')
end
function NukeVim:health()
health = vim.health or require "health"
-- TODO: Figure out a way to determine if a module is actually loaded
-- and/or add some error handling to some requires() so we can track that
-- and report it here.
for name, module in pairs(self.modules.modules) do
check = module.instance:health()
if (check ~= nil) then
health.report_start(('Module: %s'):format(name))
for idx,message in ipairs(check.messages) do
health['report_' .. message[1]](message[2])
end
end
end
end
return NukeVim

Loading…
Cancel
Save