goolord / alpha-nvim

a lua powered greeter like vim-startify / dashboard-nvim
MIT License
1.82k stars 109 forks source link

What are sections? #162

Closed Gremious closed 1 year ago

Gremious commented 1 year ago

I've read the documentation but it doesn't mention much about what sections are and how to use them.

It's all a bit confusing, since the layout map can take a mix of "sections" and arbitrary user elements together e.g.

config.layout = {
    section.header,
    { type = 'padding', val = 2 },
    section.buttons,
    ...
}

but then the sections are pretty much fully configurable anyway?

Also the doc mention a buttons as well as a top_buttons section (which also implies a bottom_buttons), though top_buttons isn't real anymore I think since I get a lua error on trying to use that. With that said:

  1. What are the sections, e.g. when do I prefer to use section.buttons as opposed to just putting buttons in the layout?
  2. Are they just groups e.g. { type = 'group', val = { ... } } or are they treated in any special way by alpha? Asking because they seem to be in a separate field, outside of layout.
  3. Is there just a list of all possible sections and what they're supposed to represent?
  4. Can I make my own sections, and if so, how?
  5. Please consider adding this information into the documentation.

Thanks 👍

Gremious commented 1 year ago

Ok after enough running different nestings of :lua print(vim.inspect(require("alpha.themes.dashboard"))) and a bit of source reading I think I figured out and already, and am leaving my answer for other people, cause there's not enough docs I say and the dichotomy between "groups" and "sections" is confusing to new users.

What are sections / Are they just groups? Yes - just a group, not special. See: https://github.com/goolord/alpha-nvim/blob/d2336550abec27c6af8be4ed5045fb4fa82a9c93/lua/alpha/themes/dashboard.lua#L75

When to prefer using them. When you wanna group things together and maybe move them together. You can insert more things at the end of existing sections in any regular lua way, e.g. with table.insert(config.layout.buttons, { ... }) (doc) or what not.

Can I make my own They are just a lua table, stored separately for convenience.

Would still like sections mentions in the docs, in relations to groups.

goolord commented 1 year ago

yeah, you have the right idea. I just wanted to provide a simpler api for doing small mutations to alpha themes, like changing the header text or something.

goolord commented 1 year ago

it's kinda a quirk of lua i suppose, the layout array is really a table with number indexes, if you give them a string as the key it can sort the table in funny ways

Gremious commented 1 year ago

Yeah that's reasonable, and honestly appreciated - now that I know what it does it does it makes sense.