Attempt to index a nil value
Closed this issue · 4 comments
The full error message is as follow:
packer.nvim: Error running config for heirline.nvim: ...m/lua/plugins/general/statusline/heir
line/statusline.lua:405: attempt to index a nil value
In the hairline config, the line number 405 is as follows:
error_icon = vim.fn.sign_getdefined("DiagnosticSignError")[1].text,
I found a temporary solution using the after
option in packer to load my colorscheme
plugin before heirline:
use {
'rebelot/heirline.nvim',
requires = 'kyazdani42/nvim-web-devicons',
config = function()
require('plugins/general/statusline/heirline')
end,
after = 'onedarkpro.nvim'
}
But this hasn't always been the case and I want to know why this is happening.
this is a duplicate issue, and it is happening because diagnostic signs are not defined at the time your heirline configuration is sourced. Idk where you define diagnostic symbols, but you should do so before loading heirline. Of course, the snippet in the cookbook is just to ensure consistency with your icons, but you can "hardcode" them anyway you like it.
a probably useful tip is to load heirline on "VimEnter"
or "UiEnter"
using packer/lazy event
field. This increases the chances that icons/colors are already loaded before heirline
I understood your point but I was using the same config without any errors previously.
Either onedarkpro.nvim or heirline.nvim changed something that's caused this(maybe lsp-config too)
Nothing in heirline could cause this problem, you should realise the cookbook configuration is all user-side. You could use any symbol for diagnostic errors, line 405 could also be
error_icon = "ERR",
the fact that vim.fn.sign_getdefined("DiagnosticSignError")[1]
is not nil
at the time your config file is required is entirely user responsibility.