[HELP WANTED ๐] Lazy Loading Problem?
Closed this issue ยท 3 comments
Description
Hi, I was following the instructions provided in the cookbook.md from this repository. However, when I attempted to load my plugins using the Lazy
plugin manager, I encountered the following error:
Failed to run `config` for heirline.nvim
...4/.config/GruVim/lua/configs/ui/statuslines/heirline.lua:230: attempt to index a nil value
# stacktrace:
- lua/configs/ui/statuslines/heirline.lua:230
- vim/_editor.lua:0 _in_ **cmd**
- lua/functions/cmd.lua:20
The error is related to the code in the Diagnostics
table:
local Diagnostics = {
condition = conditions.has_diagnostics,
static = {
error_icon = vim.fn.sign_getdefined("DiagnosticSignError")[1].text,
warn_icon = vim.fn.sign_getdefined("DiagnosticSignWarn")[1].text,
info_icon = vim.fn.sign_getdefined("DiagnosticSignInfo")[1].text,
hint_icon = vim.fn.sign_getdefined("DiagnosticSignHint")[1].text,
},
init = function(self)
self.errors = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR })
self.warnings = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN })
self.hints = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.HINT })
self.info = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.INFO })
end,
update = { "DiagnosticChanged", "BufEnter" },
{
provider = "",
},
{
provider = function(self)
-- 0 is just another output, we can decide to print it or not!
return self.errors > 0 and (self.error_icon .. self.errors .. " ")
end,
hl = { fg = "diag_error" },
},
{
provider = function(self)
return self.warnings > 0 and (self.warn_icon .. self.warnings .. " ")
end,
hl = { fg = "diag_warn" },
},
{
provider = function(self)
return self.info > 0 and (self.info_icon .. self.info .. " ")
end,
hl = { fg = "diag_info" },
},
{
provider = function(self)
return self.hints > 0 and (self.hint_icon .. self.hints)
end,
hl = { fg = "diag_hint" },
},
{
provider = "",
},
}
Weirdly enough, this error is inconsistent to produce. See below.
Steps To Reproduce
- Run
:Lazy load all
. - It either successfully loads the statusline, or it produces the previously mentioned error.
Attempts To Resolve The Problem
I have tried several approaches to resolve the problem, but none have been successful so far:
- Loading my plugins with different priority values set.
- Sequentially loading the colorscheme first, followed by LSP-related plugins, the statusline, and the rest of my plugins.
Note: I have been using the Packer
plugin manager for quite some time but recently decided to switch to the Lazy
plugin manager, so I'm not sure if I have configured everything properly. Here is the link to my configuration. Any help is greatly appreciated, thanks!
Files That Could Be Related To The Problem
Hi @RayZ0rr , thanks for the suggestion. Unfortunately, I have already tried what you had suggested, and it did not resolve the problem. I actually ended up switching to lualine
and created my own statusline that looks very similar to one from the cookbook.
apparently I'm late, but if you use vim.fn.sign_getdefined
diagnostic symbols should be defined before heirline config is sourced.