goolord/alpha-nvim

Cannot set dashboard.section.terminal

Asthestarsfalll opened this issue · 1 comments

I attempt to add a terminal on dashboard, but it occurs an error:

Error executing lua callback: /home/xxx/.local/share/nvim/lazy/alpha-nvim/lua/alpha.lua:389: attempt to call a nil value
stack traceback:
        /home/xxx/.local/share/nvim/lazy/alpha-nvim/lua/alpha.lua:389: in function 'layout'
        /home/xxx/.local/share/nvim/lazy/alpha-nvim/lua/alpha.lua:630: in function 'draw'
        /home/xxx/.local/share/nvim/lazy/alpha-nvim/lua/alpha.lua:724: in function 'start'
        /home/xxx/.config/nvim/lua/astronvim/autocmds.lua:248: in function </home/xxx/.config/nvim/lua/astronvim/autocmds.lua:228>

My config:

return {
  "goolord/alpha-nvim",
  cmd = "Alpha",
  opts = function()
    local dashboard = require "alpha.themes.dashboard"

    dashboard.opts.opts.noautocmd = true
    dashboard.section.terminal.command = "cat " .. os.getenv "HOME" .. "/.config/nvim/lua/user/plugins/Lucy.txt"
    dashboard.section.terminal.width = 20
    dashboard.section.terminal.height = 20
    dashboard.section.terminal.opts.redraw = true

    dashboard.opts.layout = {
      { type = "padding", val = 4 },
      dashboard.section.terminal,
      { type = "padding", val = 4 },
      dashboard.section.buttons,
      dashboard.section.footer,
    }

    return dashboard
  end,
  config = function(_, opts)
    require("alpha").setup(opts.config)

    vim.api.nvim_create_autocmd("User", {
      pattern = "LazyVimStarted",
      desc = "Add Alpha dashboard footer",
      once = true,
      callback = function()
        local stats = require("lazy").stats()
        local ms = math.floor(stats.startuptime * 100 + 0.5) / 100
        opts.section.footer.val = { " ", " ", " ", "Loaded " .. stats.count .. " plugins  in " .. ms .. "ms" }
        opts.section.footer.opts.hl = "DashboardFooter"
        pcall(vim.cmd.AlphaRedraw)
      end,
    })
  end,
}

Have I done something wrong? How can I resolve this issue? Thank you in advance for your help!

alpha-nvim/doc/alpha.txt

Lines 168 to 169 in 4b36c1c

-- note: require'alpha.term' must be called
-- after require'alpha'

requiring "alpha.term" will fix this for you as per the docs, the alpha.term module functions as an extension