-
Notifications
You must be signed in to change notification settings - Fork 119
Description
Hello 👋
I'd love to be able to vertically center my Alpha dashboard.
I followed the advice here and implemented dynamic padding in my Alpha opts:
-- The content_height calculation is based on my custom Alpha config
local content_height = #opts.section.header.val + (#opts.section.buttons.val * 2 - 1) + 3
opts.opts.layout[1].val = vim.fn.floor((vim.fn.winheight(0) - content_height + 2) / 2)
The problem is this function is only run once when Neovim starts up. I often switch between my laptop and desktop, which means that Alpha is always going to be off on one of them.
I think there are a couple of solutions to this issue:
-
Allow the padding to be calculated dynamically. Rather than providing a value to
opts.opts.layout[1].val
, you could allow a function that returns the value to be passed. Then, Alpha could call this function on every render, which would achieve dynamic padding.opts.opts.layout[1].val = function() local content_height = #opts.section.header.val + (#opts.section.buttons.val * 2 - 1) + 3 return vim.fn.floor((vim.fn.winheight(0) - content_height + 2) / 2) end
-
Provide a setting for vertically centering content. To me, this would be better DX, and would avoid requiring the settings to understand and calculate the dashboard height.
Thank you!