[Question] when I try to change the color I get an error, am I doing something wrong?
Closed this issue · 6 comments
so I read some issues and looked at documentation and I imagine that this
dashboard.section.header.opts.hl = {{'Normal guifg=White', 0, 1}}
should not throw any errors (this is not meant to actually be what I use or a correct range, it's just to test out as I am new to nvim)
but I get the error
Error executing lua callback: ...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:365: attempt to call a nil value
stack traceback:
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:365: in function <...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:344>
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:389: in function 'layout'
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:630: in function 'draw'
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:724: in function 'start'
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:774: in function <...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:772>
what am I doing wrong?
actually now it just does that, even after I deleted that line, it must be something else in my config (I'm using lazy.nvim)
return {
'goolord/alpha-nvim',
config = function()
local alpha = require("alpha")
local dashboard = require("alpha.themes.dashboard")
-- Set header
dashboard.section.header.val = {
[[ /\\\\\ /\\\ /\\\\\\\\\\\\\\\ /\\\\\ /\\\ /\\\ /\\\\\\\\\\\ /\\\\ /\\\\ ]],
[[ \/\\\\\\ \/\\\ \/\\\/////////// /\\\///\\\ \/\\\ \/\\\ \/////\\\/// \/\\\\\\ /\\\\\\ ]],
[[ \/\\\/\\\ \/\\\ \/\\\ /\\\/ \///\\\ \//\\\ /\\\ \/\\\ \/\\\//\\\ /\\\//\\\ ]],
[[ \/\\\//\\\ \/\\\ \/\\\\\\\\\\\ /\\\ \//\\\ \//\\\ /\\\ \/\\\ \/\\\\///\\\/\\\/ \/\\\ ]],
[[ \/\\\\//\\\\/\\\ \/\\\/////// \/\\\ \/\\\ \//\\\ /\\\ \/\\\ \/\\\ \///\\\/ \/\\\ ]],
[[ \/\\\ \//\\\/\\\ \/\\\ \//\\\ /\\\ \//\\\/\\\ \/\\\ \/\\\ \/// \/\\\ ]],
[[ \/\\\ \//\\\\\\ \/\\\ \///\\\ /\\\ \//\\\\\ \/\\\ \/\\\ \/\\\ ]],
[[ \/\\\ \//\\\\\ \/\\\\\\\\\\\\\\\ \///\\\\\/ \//\\\ /\\\\\\\\\\\ \/\\\ \/\\\ ]],
[[ \/// \///// \/////////////// \///// \/// \/////////// \/// \/// ]],
}
-- Set menu
dashboard.section.buttons.val= {
type = "group",
val = {
{ type = "text", val = "Quick links", opts = { hl = "SpecialComment", position = "center" } },
{ type = "padding", val = 1 },
dashboard.button("e", " New file", "<cmd>ene<CR>"),
dashboard.button("u", " Update plugins", "<cmd>Lazy sync<CR>"),
dashboard.button("q", " Quit", "<cmd>qa<CR>"),
},
position = "center",
}
-- Send config to alpha
alpha.setup(dashboard.opts)
-- Disable folding on alpha buffer
vim.cmd([[
autocmd FileType alpha setlocal nofoldenable
]])
end
};
alpha uses these as arguments to vim.api.nvim_buf_add_highlight
, i don't think 'Normal guifg=White'
is a valid highlight group. you probably need to create a new highlight group and set guifg there
thank you, I'm just starting out and I got confused reading the docs, I'll do as you say
hi again, sorry to disturb you with dumb questions again, but I keep getting errors:
Error executing lua callback: ...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:164: attempt to compare nil with number
stack traceback:
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:164: in function 'single_line'
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:188: in function 'highlight'
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:238: in function <...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:202>
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:389: in function 'layout'
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:630: in function 'draw'
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:724: in function 'start'
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:774: in function <...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:772>
for both dashboard.section.header.opts.hl = 'top_of_mlm'
and dashboard.section.header.opts.hl = {'top_of_mlm', 1, 118}
and error
Error executing lua callback: ...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:365: attempt to call a nil value
stack traceback:
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:365: in function <...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:344>
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:389: in function 'layout'
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:630: in function 'draw'
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:724: in function 'start'
...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:774: in function <...io/AppData/Local/nvim-data/lazy/alpha-nvim/lua/alpha.lua:772>
for
dashboard.section.header.opts.hl = {
{'top_of_mlm', 1, 118},
{'top_of_mlm', 121, 238},
{'top_middle_of_mlm', 241, 358},
{'top_middle_of_mlm', 361, 478},
{'middle_of_mlm', 481, 598},
{'bottom_middle_of_mlm', 601, 718},
{'bottom_middle_of_mlm', 721, 838},
{'bottom_of_mlm', 841, 958},
{'bottom_of_mlm', 961, 1078},
}
I set up the the highlights like this:
vim.api.nvim_create_namespace("top_of_mlm")
vim.api.nvim_create_namespace("top_middle_of_mlm")
vim.api.nvim_create_namespace("middle_of_mlm")
vim.api.nvim_create_namespace("bottom_middle_of_mlm")
vim.api.nvim_create_namespace("bottom_of_mlm")
vim.api.nvim_set_hl(0, "top_of_mlm", {fg = "#078d70"})
vim.api.nvim_set_hl(0, "top_middle_of_mlm", {fg = "#98e8c1"})
vim.api.nvim_set_hl(0, "middle_of_mlm", {fg = "#ffffff"})
vim.api.nvim_set_hl(0, "bottom_middle_of_mlm", {fg = "#7bade2"})
vim.api.nvim_set_hl(0, "bottom_of_mlm", {fg = "#3d1a78"})
in a separate file
what am I doing wrong here?
edit: here is what the header is set to:
dashboard.section.header.val = {
[[ /\\\\\ /\\\ /\\\\\\\\\\\\\\\ /\\\\\ /\\\ /\\\ /\\\\\\\\\\\ /\\\\ /\\\\ ]],
[[ \/\\\\\\ \/\\\ \/\\\/////////// /\\\///\\\ \/\\\ \/\\\ \/////\\\/// \/\\\\\\ /\\\\\\ ]],
[[ \/\\\/\\\ \/\\\ \/\\\ /\\\/ \///\\\ \//\\\ /\\\ \/\\\ \/\\\//\\\ /\\\//\\\ ]],
[[ \/\\\//\\\ \/\\\ \/\\\\\\\\\\\ /\\\ \//\\\ \//\\\ /\\\ \/\\\ \/\\\\///\\\/\\\/ \/\\\ ]],
[[ \/\\\\//\\\\/\\\ \/\\\/////// \/\\\ \/\\\ \//\\\ /\\\ \/\\\ \/\\\ \///\\\/ \/\\\ ]],
[[ \/\\\ \//\\\/\\\ \/\\\ \//\\\ /\\\ \//\\\/\\\ \/\\\ \/\\\ \/// \/\\\ ]],
[[ \/\\\ \//\\\\\\ \/\\\ \///\\\ /\\\ \//\\\\\ \/\\\ \/\\\ \/\\\ ]],
[[ \/\\\ \//\\\\\ \/\\\\\\\\\\\\\\\ \///\\\\\/ \//\\\ /\\\\\\\\\\\ \/\\\ \/\\\ ]],
[[ \/// \///// \/////////////// \///// \/// \/////////// \/// \/// ]],
}
you have to change this line
dashboard.section.buttons.val= {
to this
dashboard.section.buttons= {
otherwise your data is laid out wrong. I admit error messages for that could be a little better, eventually i will write a table validation function
@Dario48true sorry for the late response, I don't have a lot of energy to answer questions lately
@goolord don't worry about the late reply, rather thank you for replying at all, you had nothing forcing you to do it and you did it, and I am extremely thankful for that, you are a great dev