diff options
| author | moxie <moxie@3kgcat.fi> | 2026-03-13 09:58:53 +0200 |
|---|---|---|
| committer | moxie <moxie@3kgcat.fi> | 2026-03-13 09:58:53 +0200 |
| commit | bc2944651f4dabc68d7f34c796400d80ba132016 (patch) | |
| tree | 3655716442a24ccb758983f0ddc89222916f64c1 /lua/muwiki/health.lua | |
chore: init
Diffstat (limited to 'lua/muwiki/health.lua')
| -rw-r--r-- | lua/muwiki/health.lua | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/lua/muwiki/health.lua b/lua/muwiki/health.lua new file mode 100644 index 0000000..a118cc8 --- /dev/null +++ b/lua/muwiki/health.lua @@ -0,0 +1,69 @@ + +local fs = require('muwiki.fs') + +local M = {} + +local function command_exists(cmd) + if type(cmd) == 'function' then + return true + end + return vim.fn.executable(cmd) == 1 +end + +M.check = function() + vim.health.start('Wiki Setup') + + local ok, config = pcall(require, 'muwiki.config') + if not ok then + vim.health.error('Failed to load muwiki.config module') + return + end + + local cfg = config.options + + if not cfg.dirs or #cfg.dirs == 0 then + vim.health.error('No wiki directories configured') + vim.health.info('Add to your config: dirs = {{name = "default", path = "~/wiki"}}') + else + for _, dir in ipairs(cfg.dirs) do + if fs.dir_exists(dir.path) then + vim.health.ok(string.format("Wiki '%s': %s", dir.name, dir.path)) + else + vim.health.warn(string.format("Wiki '%s': %s (not found)", dir.name, dir.path)) + end + end + end + + vim.health.start('External Handlers') + + if cfg.use_external_handlers then + vim.health.ok('External handlers are enabled') + + for _, handler in ipairs(cfg.external_handlers) do + if type(handler.cmd) == 'function' then + vim.health.ok(string.format("Handler '%s': <Lua function>", handler.name)) + elseif command_exists(handler.cmd) then + vim.health.ok(string.format("Handler '%s': %s", handler.name, handler.cmd)) + else + vim.health.error( + string.format("Handler '%s': command not found (%s)", handler.name, handler.cmd) + ) + end + end + else + vim.health.info('External handlers are disabled') + end + + vim.health.start('Treesitter (Required)') + + local has_ts_parser = pcall(vim.treesitter.get_parser, 0, 'markdown') + if has_ts_parser then + vim.health.ok('Treesitter markdown parser is installed') + else + vim.health.error('Treesitter markdown parser not installed') + vim.health.info('Install with: :TSInstall markdown') + vim.health.info('Link detection requires treesitter') + end +end + +return M |
