Closed ArcticOc closed 2 years ago
i can't tell without seeing any of your configuration's code, but i suspect that you are setting
dashboard.section.footer = footer()
instead of dashboard.section.footer.val = footer()
Unluckily, I'm just setting dashboard.section.footer.val = footer()
Here is the whole normal alpha.lua
local status_ok, alpha = pcall(require, "alpha")
if not status_ok then
return
end
local dashboard = require "alpha.themes.dashboard"
dashboard.section.header.val = {}
dashboard.section.buttons.val = {
dashboard.button("f", " " .. " Find file", ":Telescope find_files <CR>"),
dashboard.button("e", " " .. " New file", ":ene <BAR> startinsert <CR>"),
dashboard.button("p", " " .. " Find project", ":lua require('telescope').extensions.projects.projects()<CR>"),
dashboard.button("r", " " .. " Recent files", ":Telescope oldfiles <CR>"),
dashboard.button("t", " " .. " Find text", ":Telescope live_grep <CR>"),
dashboard.button("u", " " .. " Update Plugins", ":PackerSync<CR>"),
dashboard.button("c", " " .. " Config", ":e ~/.config/nvim/init.lua <CR>"),
dashboard.button("q", " " .. " Quit", ":qa<CR>"),
}
--footer
local function footer()
return {}
end
dashboard.section.footer.val = footer()
dashboard.section.footer.opts.hl = "Type"
dashboard.section.header.opts.hl = "Include"
dashboard.section.buttons.opts.hl = "Keyword"
dashboard.opts.opts.noautocmd = true
alpha.setup(dashboard.opts)
footer.val
should have the lua type string
here but that footer function returns a table
Sorry, I'm a beginner. What should I do? Just like this?
local function footer() return string.format() end
Sorry, I'm a beginner. What should I do? Just like this?
local function footer() return string.format() end
I've try it. It fails to work with the same error.
no problem, so there are eight basic types in Lua: nil, boolean, number, string, function, userdata, thread, and table.
alpha at its core has its startup screen functionality wrapped around a little language for expressing layouts with lua tables.
the footer for dashboard is a table where the alpha type has been set to "text", which has 3 documented acceptable value types. https://github.com/goolord/alpha-nvim/blob/main/doc/alpha.txt#L102 val = "string" | { "array" } | function
(array
being a table where the keys are numbers)
so you set
local function footer()
local plugins = #vim.tbl_keys(packer_plugins)
local v = vim.version()
local datetime = os.date " %d-%m-%Y %H:%M:%S"
return string.format(" %d v%d.%d.%d %s %s", plugins, v.major, v.minor, v.patch, datetime)
end
dashboard.section.footer.val = footer()
your problem upon closer inspection is that the packer_plugins
you pass to tbl_keys
here
local plugins = #vim.tbl_keys(packer_plugins)
doesn't exist, and is thus nil
, and the function vim.tbl_keys
makes an assertion that the argument you pass is of type table
.
I just read the packer's manual, packer_plugins
should be indeed a global table. But something went wrong with packer_plugins
. Thanks for your help.
I figure that out, just
require ("packer_compiled")
I want to imitate this nice theme, which can show the number of plugins and date inside the footer.
SO I insert the following code into my alpha.lua.
Then nvim casts the expected table got nil error.