goolord / alpha-nvim

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

Suggested fortune setup gives `attempt to call a nil value` with startify theme #112

Closed bew closed 2 years ago

bew commented 2 years ago

my config for startify theme:

  local theme = require"alpha.themes.startify"
  theme.section.footer.val = require"alpha.fortune"()
  require"alpha".setup(theme.config)

error:

Error detected while processing VimEnter Autocommands for "*":
E5108: Error executing lua .../share/nvim-wip/managed-plugins/alpha-nvim/lua/alpha.lua:302: attempt to call a nil value
stack traceback:
        .../share/nvim-wip/managed-plugins/alpha-nvim/lua/alpha.lua:302: in function <.../share/nvim-wip/managed-plugins/alpha
-nvim/lua/alpha.lua:293>
        .../share/nvim-wip/managed-plugins/alpha-nvim/lua/alpha.lua:326: in function 'layout'
        .../share/nvim-wip/managed-plugins/alpha-nvim/lua/alpha.lua:540: in function 'draw'
        .../share/nvim-wip/managed-plugins/alpha-nvim/lua/alpha.lua:567: in function 'start'
        [string ":lua"]:1: in main chunk

it does work with the dashboard theme.

Shivix commented 2 years ago

setting theme.section.footer.type = "text" should fix it. Should "text" be default for footer @goolord ?

goolord commented 2 years ago

that is indeed one fix, or

theme.section.footer.val = {
  { 
     type = "text",
     val = require"alpha.fortune"()
  }
}

perhaps there should be more consistency between how you configure the two themes, idk, but the current behavior is intentional

bew commented 2 years ago

Okay, well thank you I learned a few things :)

bew commented 2 years ago
theme.section.footer = {
  { 
     type = "text",
     val = require"alpha.fortune"()
  }
}

I think you meant:

theme.section.footer.val = {
...

otherwise you're redefining the footer section, and that new section table isn't referenced in the config layout.