aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/health.lua
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2024-05-25 20:35:37 +0200
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2024-05-27 20:48:46 +0200
commit6e8a728e3dad747d0c46dc47a530b76e8997bc08 (patch)
tree694dfdf6f734aed15c4944f8b0e8733abde802e4 /runtime/lua/vim/health.lua
parentf70af5c3cad098ee9c7f1956bc18991cbd515507 (diff)
downloadrneovim-6e8a728e3dad747d0c46dc47a530b76e8997bc08.tar.gz
rneovim-6e8a728e3dad747d0c46dc47a530b76e8997bc08.tar.bz2
rneovim-6e8a728e3dad747d0c46dc47a530b76e8997bc08.zip
refactor: fix luals type warnings
Diffstat (limited to 'runtime/lua/vim/health.lua')
-rw-r--r--runtime/lua/vim/health.lua12
1 files changed, 7 insertions, 5 deletions
diff --git a/runtime/lua/vim/health.lua b/runtime/lua/vim/health.lua
index afeba2ee9d..236f9da752 100644
--- a/runtime/lua/vim/health.lua
+++ b/runtime/lua/vim/health.lua
@@ -104,10 +104,10 @@ local function filepath_to_healthcheck(path)
local subpath = path:gsub('.*lua/', '')
if vim.fs.basename(subpath) == 'health.lua' then
-- */health.lua
- name = assert(vim.fs.dirname(subpath))
+ name = vim.fs.dirname(subpath)
else
-- */health/init.lua
- name = assert(vim.fs.dirname(assert(vim.fs.dirname(subpath))))
+ name = vim.fs.dirname(vim.fs.dirname(subpath))
end
name = name:gsub('/', '.')
@@ -301,11 +301,13 @@ end
local PATTERNS = { '/autoload/health/*.vim', '/lua/**/**/health.lua', '/lua/**/**/health/init.lua' }
--- :checkhealth completion function used by cmdexpand.c get_healthcheck_names()
M._complete = function()
- local unique = vim
+ local unique = vim ---@type table<string,boolean>
+ ---@param pattern string
.iter(vim.tbl_map(function(pattern)
return vim.tbl_map(path2name, vim.api.nvim_get_runtime_file(pattern, true))
end, PATTERNS))
:flatten()
+ ---@param t table<string,boolean>
:fold({}, function(t, name)
t[name] = true -- Remove duplicates
return t
@@ -364,7 +366,7 @@ function M._check(mods, plugin_names)
vim.fn.call(func, {})
else
local f = assert(loadstring(func))
- local ok, output = pcall(f)
+ local ok, output = pcall(f) ---@type boolean, string
if not ok then
M.error(
string.format('Failed to run healthcheck for "%s" plugin. Exception:\n%s\n', name, output)
@@ -391,7 +393,7 @@ function M._check(mods, plugin_names)
end
s_output[#s_output + 1] = ''
s_output = vim.list_extend(header, s_output)
- vim.fn.append('$', s_output)
+ vim.fn.append(vim.fn.line('$'), s_output)
vim.cmd.redraw()
end