| 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
 | local M = {}
function M.report_start(msg)
  vim.fn['health#report_start'](msg)
end
function M.report_info(msg)
  vim.fn['health#report_info'](msg)
end
function M.report_ok(msg)
  vim.fn['health#report_ok'](msg)
end
function M.report_warn(msg, ...)
  vim.fn['health#report_warn'](msg, ...)
end
function M.report_error(msg, ...)
  vim.fn['health#report_error'](msg, ...)
end
local path2name = function(path)
  if path:match('%.lua$') then
    -- Lua: transform "../lua/vim/lsp/health.lua" into "vim.lsp"
    -- Get full path, make sure all slashes are '/'
    path = vim.fs.normalize(path)
    -- Remove everything up to the last /lua/ folder
    path = path:gsub('^.*/lua/', '')
    -- Remove the filename (health.lua)
    path = vim.fn.fnamemodify(path, ':h')
    -- Change slashes to dots
    path = path:gsub('/', '.')
    return path
  else
    -- Vim: transform "../autoload/health/provider.vim" into "provider"
    return vim.fn.fnamemodify(path, ':t:r')
  end
end
local PATTERNS = { '/autoload/health/*.vim', '/lua/**/**/health.lua', '/lua/**/**/health/init.lua' }
-- :checkhealth completion function used by ex_getln.c get_healthcheck_names()
M._complete = function()
  local names = vim.tbl_flatten(vim.tbl_map(function(pattern)
    return vim.tbl_map(path2name, vim.api.nvim_get_runtime_file(pattern, true))
  end, PATTERNS))
  -- Remove duplicates
  local unique = {}
  vim.tbl_map(function(f)
    unique[f] = true
  end, names)
  -- vim.health is this file, which is not a healthcheck
  unique['vim'] = nil
  return vim.tbl_keys(unique)
end
return M
 |