-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash in highlight.lua at line 106 (attempt to perform arithmetic on local 'n' (nil value)) with certain color configurations #260
Comments
Until this is fixed on master, it can be avoided by pinning the version to the commit before the bug was introduced, this on use {
'ggandor/leap.nvim',
commit = '5ae080b646021bbb6e1d8715b155b1e633e28166',
config = function() require('leap').create_default_mappings() end
} |
Same issue here, it seems it is affecting everyone |
Same is occurring on my end. I'm doing also locking to a previous commit to bypass. I was using a transparent background as well. |
Thanks for reporting, sorry for the slow response. I specifically checked this before commiting, in my config |
All of you are using transparent backgrounds? @Kerim-Willem I guess we can parse the strings if necessary then, but I'd like to get to the bottom of this first :) |
I'm using transparent background too and after update 50045fa i got:
My theme config: -- lazy.nvim
return {
"navarasu/onedark.nvim",
-- lazy = false,
-- priority = 1000,
config = function()
require("onedark").setup {
transparent = true,
highlights = {
TabLine = { bg = "none" },
TabLineFill = { bg = "none" },
FloatBorder = { bg = "none", fg = "#707880" },
NormalFloat = { bg = "none", fg = "#707880" },
Pmenu = { bg = "none" },
StatusLine = { bg = "none" },
},
}
vim.api.nvim_create_autocmd("Colorscheme", {
group = vim.api.nvim_create_augroup("config_custom_highlights", {}),
callback = function()
-- Removes background from barbar
vim.api.nvim_set_hl(0, "BufferCurrentADDED", { bg = "none", fg = "#7EA662" })
vim.api.nvim_set_hl(0, "BufferCurrentCHANGED", { bg = "none", fg = "#4FA6ED" })
vim.api.nvim_set_hl(0, "BufferCurrentDELETED", { bg = "none", fg = "#E55561" })
end,
})
vim.cmd "colorscheme onedark"
end,
} |
67d26a1 fixed error for me UPD: Thank you! |
I’m encountering two persistent errors in Neovim/LazyVim whenever I press s, likely due to having a fully transparent background in my setup.
Right after I start Neovim, pressing s produces the following message:
E5108: Error executing lua: ...kerim/.local/share/nvim/lazy/leap.nvim/lua/leap/init.lua:5:
loop or previous error loading module 'leap.main'
stack traceback:
[C]: in function 'require'
...kerim/.local/share/nvim/lazy/leap.nvim/lua/leap/init.lua:5: in function '__index'
...s/kerim/.local/share/nvim/lazy/leap.nvim/plugin/init.lua:36: in function <...s/kerim/.local/share/nvim/lazy/leap.nvim/plugin/init.lua:36>
...
Once the first error clears, pressing s again leads to:
E5108: Error executing lua: ...kerim/.local/share/nvim/lazy/leap.nvim/lua/leap/init.lua:5:
loop or previous error loading module 'leap.main'
stack traceback:
[C]: in function 'require'
...kerim/.local/share/nvim/lazy/leap.nvim/lua/leap/init.lua:5: in function '__index'
...s/kerim/.local/share/nvim/lazy/leap.nvim/plugin/init.lua:36: in function <...s/kerim/.local/share/nvim/lazy/leap.nvim/plugin/init.lua:36>
...
This second error repeats every time I press s.
It appears that blend(color1, color2, weight) expects color1 and color2 to be decimal numbers, but in my configuration, nvim_get_hl() sometimes returns a hex string (e.g., "#ffffff") or nil. That causes math.floor(n / 65536) to fail.
Proposed Fix:
In highlight.lua (around line 106), blend() calls a helper like __3ergb(n). If n is either nil or a hex string, the code crashes. A straightforward workaround is to check for these cases and convert them to a fallback numeric value. For example:
This worked for me!
`
local function blend(color1, color2, weight)
local function __3ergb(n)
if not n then
-- fallback to black
return 0, 0, 0
elseif type(n) == "string" then
-- parse something like "#ffffff" into a number
local hex = n:gsub("^#", "")
local num = tonumber(hex, 16) or 0
local r = math.floor(num / 65536)
local g = math.floor((num / 256) % 256)
local b = num % 256
return r, g, b
else
-- n is already a decimal
local r = math.floor(n / 65536)
local g = math.floor((n / 256) % 256)
local b = n % 256
return r, g, b
end
end
local r1, g1, b1 = __3ergb(color1)
local r2, g2, b2 = __3ergb(color2)
end
`
With this patch, Leap no longer crashes and works like expected. I’d be happy to open a PR if this approach seems acceptable. I hope this helps anyone that got stuck like I did!
The text was updated successfully, but these errors were encountered: