chaozwn / astronvim_with_coc_or_mason

astronvim_config
102 stars 25 forks source link

Error when load nvim barbecue in function 'get_file_icon' #21

Closed Thesoul20 closed 2 months ago

Thesoul20 commented 3 months ago

When I open nvim at any folder, there is a error appear:

Error executing vim.schedule lua callback: ...e/.local/share/nvim/lazy/barbecue/lua/barbecue/theme.lua:172: table index is nil
stack traceback:
        ...e/.local/share/nvim/lazy/barbecue/lua/barbecue/theme.lua:172: in function 'get_file_icon'
        .../share/nvim/lazy/barbecue/lua/barbecue/ui/components.lua:82: in function 'basename'
        ...oose/.local/share/nvim/lazy/barbecue/lua/barbecue/ui.lua:106: in function 'create_entries'
        ...oose/.local/share/nvim/lazy/barbecue/lua/barbecue/ui.lua:219: in function <...oose/.local/share/nvim/lazy/barbecue/lua/barbecue/ui.lua:203>

the theme.lua file at the folder of ~/.local/share/nvim/lazy/barbecue/lua/barbecue/.

In the theme.lua at line 168, the code are below:

  if file_icons[icon.name] == nil then
    file_icons[icon.name] = {
      highlight = highlight,
      color = icon.color,
    }

How to Fix this error.

chaozwn commented 3 months ago

it's barbecue code problem, any time you open a file he doesn't support, you get an error. if you don't want to use it, maybe you can disabled it or switch to dropbar.nvim. run :set filetype? then you will get a filetype. and add it in exclude_filetypes.

return {
  "utilyre/barbecue.nvim",
  name = "barbecue",
  version = "*",
  dependencies = {
    "SmiteshP/nvim-navic",
    "nvim-tree/nvim-web-devicons", -- optional dependency
  },
  opts = {
    show_modified = true,
    exclude_filetypes = { "netrw", "toggleterm", "gomod", "gosum" },
  },
}
chaozwn commented 3 months ago

I saw a guy come up with a nice commit, you update my code and then update the plugin, it should all be fixed.

Thesoul20 commented 3 months ago

Thank you for quickly response. In the file of nvim/lua/plugins/barbecue.lua I have change this file's context :

return {
  "utilyre/barbecue.nvim",
  name = "barbecue",
  version = "*",
  dependencies = {
    "SmiteshP/nvim-navic",
    "nvim-tree/nvim-web-devicons", -- optional dependency
  },
  opts = {
    show_modified = true,
    exclude_filetypes = { "netrw", "toggleterm", "gomod", "gosum" },
  },
}

And then I press pU to update all I used plugins.

image

Then I exit my terminal iTerm2, and reopen it. After that, run the command nvim . to enter neovim again:

Error executing vim.schedule lua callback: ...e/.local/share/nvim/lazy/barbecue/lua/barbecue/theme.lua:172: table index is nil
stack traceback:
        ...e/.local/share/nvim/lazy/barbecue/lua/barbecue/theme.lua:172: in function 'get_file_icon'
        .../share/nvim/lazy/barbecue/lua/barbecue/ui/components.lua:82: in function 'basename'
        ...oose/.local/share/nvim/lazy/barbecue/lua/barbecue/ui.lua:106: in function 'create_entries'
        ...oose/.local/share/nvim/lazy/barbecue/lua/barbecue/ui.lua:219: in function <...oose/.local/share/nvim/lazy/barbecue/lua/barbecue/ui.lua:203>
chaozwn commented 3 months ago

Thank you for quickly response. In the file of nvim/lua/plugins/barbecue.lua I have change this file's context :

return {
  "utilyre/barbecue.nvim",
  name = "barbecue",
  version = "*",
  dependencies = {
    "SmiteshP/nvim-navic",
    "nvim-tree/nvim-web-devicons", -- optional dependency
  },
  opts = {
    show_modified = true,
    exclude_filetypes = { "netrw", "toggleterm", "gomod", "gosum" },
  },
}

And then I press pU to update all I used plugins.

image

Then I exit my terminal iTerm2, and reopen it. After that, run the command nvim . to enter neovim again:

Error executing vim.schedule lua callback: ...e/.local/share/nvim/lazy/barbecue/lua/barbecue/theme.lua:172: table index is nil
stack traceback:
        ...e/.local/share/nvim/lazy/barbecue/lua/barbecue/theme.lua:172: in function 'get_file_icon'
        .../share/nvim/lazy/barbecue/lua/barbecue/ui/components.lua:82: in function 'basename'
        ...oose/.local/share/nvim/lazy/barbecue/lua/barbecue/ui.lua:106: in function 'create_entries'
        ...oose/.local/share/nvim/lazy/barbecue/lua/barbecue/ui.lua:219: in function <...oose/.local/share/nvim/lazy/barbecue/lua/barbecue/ui.lua:203>

it's not latest version. check update again.

Thesoul20 commented 2 months ago

After update the barbecue plugin, the problem still appear. Now, after enter neovim then press Space + p + s to check the versions of barbecue plugin, there are: image The version are same as the repo leastest tag: image

Fellow your suggestions in response https://github.com/chaozwn/astronvim_with_coc_or_mason/issues/21#issuecomment-2208027823, I have also add the filetype of neo-tree in file of ~/.config/nvim/lua/plugins/barbecue.lua

return {
  "utilyre/barbecue.nvim",
  name = "barbecue",
  version = "*",
  dependencies = {
    "SmiteshP/nvim-navic",
    "nvim-tree/nvim-web-devicons", -- optional dependency
  },
  opts = {
    show_modified = true,
    exclude_filetypes = { "netrw", "toggleterm", "gomod", "gosum", "neo-tree" },
  },
}
chaozwn commented 2 months ago

After update the barbecue plugin, the problem still appear. Now, after enter neovim then press Space + p + s to check the versions of barbecue plugin, there are: image The version are same as the repo leastest tag: image

Fellow your suggestions in response #21 (comment), I have also add the filetype of neo-tree in file of ~/.config/nvim/lua/plugins/barbecue.lua

return {
  "utilyre/barbecue.nvim",
  name = "barbecue",
  version = "*",
  dependencies = {
    "SmiteshP/nvim-navic",
    "nvim-tree/nvim-web-devicons", -- optional dependency
  },
  opts = {
    show_modified = true,
    exclude_filetypes = { "netrw", "toggleterm", "gomod", "gosum", "neo-tree" },
  },
}

in fact, this plugin is not stable enough at the moment, I have removed this plugin for now.

Thesoul20 commented 2 months ago

So I should clone your repo again?

chaozwn commented 2 months ago

So I should clone your repo again?

off course.

Thesoul20 commented 2 months ago

After clone the least repo, there is no error when run command nvim .. Thanks a lot.