Skip to content
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

LeftComponent throwing the following error: Invalid expression: "luaeval('require("galaxyline").component_decorator')("decoratorName") #241

Closed
Driuthorn opened this issue Mar 14, 2024 · 1 comment

Comments

@Driuthorn
Copy link

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.
image

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).
image

i tried to change the decorator name for one of those used in the examples folder. But it didn't worked
image

If i comment the first left section, it works without giving any error
image
(Commented section)

image
image
(Galaxyline working without problem in netrw and file)

That is my galaxyline configuration galaxyline.lua

@Driuthorn
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant