goolord / alpha-nvim

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

feature request: position for groups #186

Closed szechp closed 1 year ago

szechp commented 1 year ago

i cant set the position to align left for the dashboard theme.

here's my code, notice that both opts for header and buttons section are set to position left:

return
{
  'goolord/alpha-nvim',
  dependencies = { 'nvim-tree/nvim-web-devicons' },
  config = function()
    require 'alpha'.setup(require 'alpha.themes.startify'.config)
    local alpha = require("alpha")
    local dashboard = require("alpha.themes.dashboard")

    -- Set header
    dashboard.section.header.val = {
      [[]],
      [[]],
      [[]],
      [[]],
      [[███    ██ ███████  ██████  ██    ██ ██ ███    ███]],
      [[████   ██ ██      ██    ██ ██    ██ ██ ████  ████]],
      [[██ ██  ██ █████   ██    ██ ██    ██ ██ ██ ████ ██]],
      [[██  ██ ██ ██      ██    ██  ██  ██  ██ ██  ██  ██]],
      [[██   ████ ███████  ██████    ████   ██ ██      ██]]
    }
    dashboard.section.header.opts = { position = 'left' }
    -- Set menu
    dashboard.section.buttons.val = {
      dashboard.button("n", "  > New file", ":ene <BAR> startinsert <CR>"),
      dashboard.button("f", "  > Find file", ":cd $HOME | Telescope find_files<CR>"),
      dashboard.button("r", "  > Recent", ":Telescope oldfiles<CR>"),
      dashboard.button("t", "  > Todo", ":e .todo"),
      dashboard.button("d", "  > Dotfiles", ":e ~/.config/nvim/after/plugin/defaults.lua<cr>:cd ~/.config/nvim/lua/custom/plugins/<cr>:Neotree<cr>"),
      dashboard.button("q", "  > Quit NVIM", ":qa<CR>"),
    }
    dashboard.section.buttons.opts = { position = 'left' }
    -- Send config to alpha
    alpha.setup(dashboard.opts)

    -- Disable folding on alpha buffer
    vim.cmd([[
    autocmd FileType alpha setlocal nofoldenable
]])
  end
}

this it what comes from this:

image

goolord commented 1 year ago

you have to align each individual button, aligning groups doesn't do anything. this is somewhat intentional, but maybe as part of the API changing the group's alignment can change each element's alignment

szechp commented 1 year ago

Ah cool, can you maybe nudge me in the direction on how to do that? Dashboard.button.opts doesn't seem to work 😅

goolord commented 1 year ago
local button = function (a, b, c, d)
  local b = dashboard.button(a,b,c,d)
  b.opts.position = "left"
  return b
end

should work fine

goolord commented 1 year ago

alt implemented opts.inherit for groups @ https://github.com/goolord/alpha-nvim/commit/b6c7b5d9d6d2633722255abf2be3ecb8733e8d2d