goolord / alpha-nvim

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

Unable to use theta theme #281

Open KikeSenpai opened 6 months ago

KikeSenpai commented 6 months ago

Hi, I am unable to use the theta theme, the startify works well, I wanted to try the theta theme to get a centralized greeter page.

the error is

Failed to run `config` for alpha-nvim

...nrique.delgado/.config/nvim/lua/custom/plugins/alpha.lua:12: attempt to index field 'section' (a nil value)

# stacktrace:
  - lua/custom/plugins/alpha.lua:12 _in_ **config**
  - lua/lazy-plugins.lua:3
  - init.lua:70

This is my config for alpha

return {
  'goolord/alpha-nvim',
  dependencies = {
    'nvim-tree/nvim-web-devicons',
    'nvim-lua/plenary.nvim',
  },
  config = function()
    local alpha = require 'alpha'
    local dashboard = require 'alpha.themes.theta'
    dashboard.section.header.val = {
      [[                                                                                                                ]],
      [[                                                                                                                ]],
      [[                                                                                                                ]],
      [[  ████████                    ██           ██                    ████                         ████████          ]],
      [[         █████                ██           ██                 ████  █████                  ████                 ]],
      [[            ███               ██           ██               ███        ███                ██                    ]],
      [[             ██               ██           ██              ███           ██              ██                     ]],
      [[              ██              ██           ██              ██            ██          █████████████████████████  ]],
      [[             ██               ██           ██              ██            ██              ██                     ]],
      [[            ███                ██         ██               ██            ██               ██                    ]],
      [[         █████                  ████   ████                ██            ██                ████                 ]],
      [[  ████████                         █████                   ██            ██                   ████████          ]],
      [[                                                                                                                ]],
      [[                                                                                                                ]],
      [[                                                                                                                ]],
    }

    -- Set buttons
    dashboard.section.top_buttons.val = {
      dashboard.button('e', '  New file', ':ene <BAR> startinsert <CR>'),
    }
    dashboard.section.bottom_buttons.val = {
      dashboard.button('q', '󰅚  Quit NVIM', ':qa<CR>'),
    }

    -- Disable MRU
    dashboard.section.mru.val = { { type = "padding", val = 0 } }

    -- Set footer
    local footer = [[

      I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration.
      I will face my fear. I will permit it to pass over me and through me. And when it has gone past
      I will turn the inner eye to see its path. Where the fear has gone there will be nothing. Only I will remain.
    ]]
    dashboard.section.footer.val = {
      {
        type = 'text',
        val = footer,
      },
    }

    -- Keymaps
    vim.keymap.set('n', '<leader>a', ':Alpha<CR>', { desc = 'Goto Greeter Screen' })

    alpha.setup(dashboard.config)
  end,
}

-- vim: ts=2 sts=2 sw=2 et
nohr commented 5 months ago

theta uses buttons from the dashboard theme. I think what makes it different from dashboard is its use of recent files. since you don't need those, you can accomplish this with the dashboard theme instead. see alpha-dune.lua:

return {
  "goolord/alpha-nvim",
  dependencies = {
    "nvim-tree/nvim-web-devicons",
    "nvim-lua/plenary.nvim",
  },
  lazy = false,
  config = function()
    local alpha = require "alpha"
    local dashboard = require "alpha.themes.dashboard"

    dashboard.section.header.val = {
      [[                                                                                                                ]],
      [[                                                                                                                ]],
      [[                                                                                                                ]],
      [[  ████████                    ██           ██                    ████                         ████████          ]],
      [[         █████                ██           ██                 ████  █████                  ████                 ]],
      [[            ███               ██           ██               ███        ███                ██                    ]],
      [[             ██               ██           ██              ███           ██              ██                     ]],
      [[              ██              ██           ██              ██            ██          █████████████████          ]],
      [[             ██               ██           ██              ██            ██              ██                     ]],
      [[            ███                ██         ██               ██            ██               ██                    ]],
      [[         █████                  ████   ████                ██            ██                ████                 ]],
      [[  ████████                         █████                   ██            ██                   ████████          ]],
      [[                                                                                                                ]],
      [[                                                                                                                ]],
      [[                                                                                                                ]],
    }

    dashboard.section.buttons.val = {
      dashboard.button("e", "  New file", ":ene <BAR> startinsert <CR>"),
      dashboard.button("q", "󰅚  Quit NVIM", ":qa<CR>"),
      { type = "padding", val = 2 },
    }

    -- Set footer
    local footer = [[

      I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration.
      I will face my fear. I will permit it to pass over me and through me. And when it has gone past
      I will turn the inner eye to see its path. Where the fear has gone there will be nothing. Only I will remain.
    ]]

    dashboard.section.footer.val = footer
    dashboard.section.footer.type = "text"
    dashboard.section.footer.opts = {
      position = "center",
      hl = "Number",
    }

    -- Keymaps
    vim.keymap.set("n", "<leader>a", ":Alpha<CR>", { desc = "Goto Greeter Screen" })

    alpha.setup(dashboard.config)
  end,
}

you should end up with this:

Screenshot 2024-06-18 at 06 36 23
steven-na commented 3 months ago

Theta doesn't have the same layout as startify, so the variables have different names.

You can access the header of theta by using dashboard.header.val rather than dashboard.section.header.val

image image (My variable is named theta, while yours is dashboard) You can see the structure of the theta theme here

HeyUKonrad commented 5 days ago

Can I use the Theta theme, but still use the dashboard style header?