diff --git a/autoload/health/nukevim.vim b/autoload/health/nukevim.vim new file mode 100644 index 0000000..bf0f1fe --- /dev/null +++ b/autoload/health/nukevim.vim @@ -0,0 +1,3 @@ +function! health#nukevim#check() + lua require 'nukevim'.health(nukevim) +endfunction diff --git a/lua/module.lua b/lua/module.lua index b1a46a3..82aa373 100644 --- a/lua/module.lua +++ b/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 diff --git a/lua/module/plugins.lua b/lua/module/plugins.lua index 548782f..b167145 100644 --- a/lua/module/plugins.lua +++ b/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 diff --git a/lua/module/start.lua b/lua/module/start.lua index 58846b8..aefa33c 100644 --- a/lua/module/start.lua +++ b/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 = { diff --git a/lua/nukevim.lua b/lua/nukevim.lua index eb66cc9..89e04a9 100644 --- a/lua/nukevim.lua +++ b/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