Seemingly random error when setting text highlight groups and centring content vertically
Closed this issue · 1 comments
I'm really not sure what to make of this error. It seems to randomly happen ~50% of the time with no changes to my config whatsoever. This is the config I've got currently
local alpha = require("alpha")
local headers = require("user.config.plugins.alpha.headers").portal
local quotes = require("user.config.plugins.alpha.quotes").portal
local function centerVert(header)
return (vim.fn.winheight(0) / 2) - ((#header + 3) / 2)
end
local header = headers[math.random(#headers)]
alpha.setup({
layout = {
{ type = "padding", val = centerVert(header) },
{
type = "text",
val = header,
opts = {
position = "center",
hl = "Comment",
},
},
{ type = "padding", val = 2 },
{
type = "text",
val = quotes[math.random(#quotes)],
opts = {
position = "center",
hl = "Number",
},
},
},
})
vim.cmd("autocmd FileType alpha setlocal nofoldenable")
headers
and quotes
are just tables with portal-themed ascii art and quotes to be randomly selected from.
^ The error traceback
^ The dashboard after the error
^ The dashboard as it should be (the only difference is that I closed and re-opened neovim)
The issue seems to be with some combination of centerVert()
and setting the highlights for the header and the quote. It works perfectly if I have one or the other, but having both results in the ~50% chance of erroring.
I am using a nightly build of neovim (v0.10.0-dev-2354+g4860cc5bd
) and Neovide, but I have also tested with the v0.9.5
release in the terminal and it still happens.
After a lot more searching I have fixed this issue by replacing my centerVert()
function with headerPadding
from this comment