Center-align mini.starter footer text

Extract header_lines and compute max_header_width so the footer
can be padded to match the header's visual centering.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
xfy 2026-05-28 14:14:11 +08:00
parent 717df254c6
commit f0c6f0a1e7

View File

@ -25,26 +25,36 @@ local function get_total_plugins()
return count return count
end end
local header_lines = {
"",
" ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗",
" ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║",
" ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║",
" ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║",
" ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║",
" ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝",
"",
}
local max_header_width = 0
for _, line in ipairs(header_lines) do
max_header_width = math.max(max_header_width, vim.fn.strdisplaywidth(line))
end
starter.setup({ starter.setup({
autoopen = true, autoopen = true,
evaluate_single = false, evaluate_single = false,
items = { { name = " ", action = "", section = "" } }, items = { { name = " ", action = "", section = "" } },
header = table.concat({ header = table.concat(header_lines, "\n"),
"",
" ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗",
" ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║",
" ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║",
" ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║",
" ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║",
" ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝",
"",
}, "\n"),
footer = function() footer = function()
local uv = vim.uv or vim.loop local uv = vim.uv or vim.loop
local ms = (uv:hrtime() - _G.nvim_start_time) / 1e6 local ms = (uv:hrtime() - _G.nvim_start_time) / 1e6
local loaded = vim.tbl_count(require("lazy")._loaded) local loaded = vim.tbl_count(require("lazy")._loaded)
local total = get_total_plugins() local total = get_total_plugins()
return string.format(" Loaded %d/%d plugins in %.0f ms", loaded, total, ms) local text = string.format(" Loaded %d/%d plugins in %.0f ms", loaded, total, ms)
local text_width = vim.fn.strdisplaywidth(text)
local pad = math.floor((max_header_width - text_width) / 2)
return string.rep(" ", pad) .. text
end, end,
content_hooks = { content_hooks = {
starter.gen_hook.aligning("center", "center"), starter.gen_hook.aligning("center", "center"),