LeftComponent throwing the following error: Invalid expression: "luaeval('require("galaxyline").component_decorator')("decoratorName")
Driuthorn opened this issue · comments
I'm new to Neovim and trying to configure my first neovim setup
I liked this plugin and i'm trying to configure it using some exemple found at the Custom Galaxyline configuration (#issue).
I got as example for a first try the Zarainia setup (setup link).
Somehow it works (show in the image below), but not as expected.
I keep being warned about this error: "luaeval('require("galaxyline").component_decorator')("decoratorName")"
I get this error everytime i do an action like changing files (via Netrw).
i tried to change the decorator name for one of those used in the examples folder. But it didn't worked
If i comment the first left section, it works without giving any error
(Commented section)
(Galaxyline working without problem in netrw and file)
That is my galaxyline configuration galaxyline.lua
I've discovered what happens to do the error and solved it.
It occours because the method called to get the the File Icon Color method doesn't handle if the buffer i'm in is a plugin or netrw. So when i enter in one of those buffers that is not a file, it breaks the code.
function M.get_file_icon_color()
local filetype = vim.bo.filetype
local f_name, f_ext = get_file_info()
if user_icons[filetype] ~= nil then return user_icons[filetype][1] end
if user_icons[f_ext] ~= nil then return user_icons[f_ext][1] end
local has_devicons, devicons = pcall(require, 'nvim-web-devicons')
if has_devicons then
local icon, iconhl = devicons.get_icon(f_name, f_ext)
if icon ~= nil then
return vim.fn.synIDattr(vim.fn.hlID(iconhl), 'fg')
end
end
local icon = M.get_file_icon():match('%S+')
for k, _ in pairs(icons) do
if vim.fn.index(icons[k], icon) ~= -1 then return icon_colors[k] end
end
end
I resolved it by doing a verification if the buffer i'm in is 'Netrw' or any of my Plugins.
Commit
local function validFiletype(filetype)
if filetype == "netrw" or filetype == '' then
return false
else
for index, data in ipairs(lazyPlugins) do
if data.name == filetype then
return false
end
end
end
return true
end