aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua
diff options
context:
space:
mode:
authorYochem van Rosmalen <git@yochem.nl>2026-01-09 23:00:09 +0100
committerGitHub <noreply@github.com>2026-01-09 17:00:09 -0500
commitf19653e3706df41190fe4fb80779f5ad37795159 (patch)
tree07686db764f98f43f2d419ece0c8f4f736308983 /runtime/lua
parent445cb751e6cbe81546ddddd9384ea44b597a86d7 (diff)
downloadrneovim-f19653e3706df41190fe4fb80779f5ad37795159.tar.gz
rneovim-f19653e3706df41190fe4fb80779f5ad37795159.tar.bz2
rneovim-f19653e3706df41190fe4fb80779f5ad37795159.zip
fix(health): emit Progress message #37123
Problem: The `"Running healthchecks..."` message doesn't inform the user much and is a hack from before we got a way to emit actual progress messages. Solution: Use `nvim_echo` to emit progress messages showing the name of the report that is currently running.
Diffstat (limited to 'runtime/lua')
-rw-r--r--runtime/lua/vim/health.lua29
1 files changed, 24 insertions, 5 deletions
diff --git a/runtime/lua/vim/health.lua b/runtime/lua/vim/health.lua
index cf8181c3f6..ad9edeaf16 100644
--- a/runtime/lua/vim/health.lua
+++ b/runtime/lua/vim/health.lua
@@ -371,6 +371,24 @@ local function get_summary()
return s
end
+---Emit progress messages
+---@param len integer
+---@return fun(status: 'success'|'running', idx: integer, fmt: string, ...: any): nil
+local function progress_report(len)
+ local progress = { kind = 'progress', title = 'checkhealth' }
+
+ return function(status, idx, fmt, ...)
+ progress.status = status
+ progress.percent = status == 'success' and nil or math.floor(idx / len * 100)
+ -- percent=0 omits the reporting of percentage, so use 1% instead
+ -- progress.percent = progress.percent == 0 and 1 or progress.percent
+ progress.id = vim.api.nvim_echo({ { fmt:format(...) } }, false, progress)
+ -- extui/ui2 shows all messages at once after the healthchecks are finished.
+ -- This 1ms wait ensures the messages are shown separately
+ vim.wait(1)
+ end
+end
+
--- Runs the specified healthchecks.
--- Runs all discovered healthchecks if plugin_names is empty.
---
@@ -419,10 +437,13 @@ function M._check(mods, plugin_names)
vim.fn.setline(1, 'ERROR: No healthchecks found.')
return
end
- vim.cmd.redraw()
- vim.print('Running healthchecks...')
+ local total_checks = #vim.tbl_keys(healthchecks)
+ local progress_msg = progress_report(total_checks)
+ local check_idx = 1
for name, value in vim.spairs(healthchecks) do
+ progress_msg('running', check_idx, 'checking %s', name)
+ check_idx = check_idx + 1
local func = value[1]
local type = value[2]
s_output = {}
@@ -475,9 +496,7 @@ function M._check(mods, plugin_names)
vim.cmd.redraw()
end
- -- Clear the 'Running healthchecks...' message.
- vim.cmd.redraw()
- vim.print('')
+ progress_msg('success', 0, 'checks done')
-- Quit with 'q' inside healthcheck buffers.
vim._with({ buf = bufnr }, function()