1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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
|