aboutsummaryrefslogtreecommitdiff
path: root/lua/muwiki/health.lua
blob: 118c1fe8e6347186af59d73d8e5b2ba4c79dafe8 (plain)
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
local M = {}

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
      local stat = vim.uv.fs_stat(dir.path)
      if stat and stat.type == 'directory' 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('Treesitter')

  local has_md_parser = pcall(vim.treesitter.get_parser, 0, 'markdown')
  if has_md_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')
  end

  local has_md_inline_parser = pcall(vim.treesitter.get_parser, 0, 'markdown_inline')
  if has_md_inline_parser then
    vim.health.ok('Treesitter markdown_inline parser is installed')
  else
    vim.health.error('Treesitter markdown_inline parser not installed')
    vim.health.info('Install with: :TSInstall markdown_inline')
    vim.health.info('Link detection requires both parsers')
  end

  vim.health.start('External Dependencies')

  if vim.fn.executable('xdg-open') == 1 then
    vim.health.ok('xdg-open is installed')
  else
    vim.health.warn('xdg-open is not installed')
    vim.health.info('xdg-open is required for web and file links')
    vim.health.info('Alternative: Configure custom handlers - see :help muwiki-autocmd-open-custom')
  end
end

return M