mirror of
https://github.com/neovim/neovim.git
synced 2024-12-21 03:35:02 -07:00
d837b6d50c
Problem: https://github.com/neovim/neovim/pull/18720#issuecomment-1142614996 The vim.health module is detected as a healthcheck, which produces spurious errors: vim: require("vim.health").check() ======================================================================== - ERROR: Failed to run healthcheck for "vim" plugin. Exception: function health#check, line 20 Vim(eval):E5108: Error executing lua [string "luaeval()"]:1: attempt to call field 'check' (a nil value) stack traceback: [string "luaeval()"]:1: in main chunk Solution: Skip vim.health when discovering healthchecks.
50 lines
1.3 KiB
Lua
50 lines
1.3 KiB
Lua
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"
|
|
return path:gsub('.-lua[%\\%/]', '', 1):gsub('[%\\%/]', '.'):gsub('%.health.-$', '')
|
|
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
|