Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertically Center Content #308

Open
LandonSchropp opened this issue Oct 21, 2024 · 0 comments
Open

Vertically Center Content #308

LandonSchropp opened this issue Oct 21, 2024 · 0 comments

Comments

@LandonSchropp
Copy link

LandonSchropp commented Oct 21, 2024

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:

  1. 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
  2. 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant