romgrk / barbar.nvim

The neovim tabline plugin.
2.26k stars 85 forks source link

Error detected when starting neovim without or with an empty buffer #482

Closed eelcocramer closed 1 year ago

eelcocramer commented 1 year ago

Description

When I start neovim without passing in a file to open, or the file that is passed does not yet exists. I see an error message stating:

Error detected while processing BufWinEnter Autocommands for "*":
Barbar detected an error while running. Barbar disabled itself :/ Include this in your report: .../.local/share/nvim/lazy/barbar.nvim/lua/barbar/icons.lua:72: attempt to concatenate local 'icon_hl' (a nil value)

I use neovim v0.9.0 together with astrovim.

I load barbar using lazy which is included in Astrovim.

To Reproduce

Steps to reproduce the behavior:

  1. Install astromvim
  2. Add config for barbar in .config/nvim/lua/user/plugins/barbar.lua
return {
  "romgrk/barbar.nvim",
  dependencies = {
    "lewis6991/gitsigns.nvim",     -- OPTIONAL: for git status
    "nvim-tree/nvim-web-devicons", -- OPTIONAL: for file icons
  },
  init = function() vim.g.barbar_auto_setup = false end,
  opts = {
    -- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default:
    -- animation = true,
    -- insert_at_start = true,
    -- …etc.
  },
  version = "^1.0.0", -- optional: only update when a new 1.x version is released
  keys = {
    -- removed key config for readibility
  },
  lazy = false,
}
  1. Open neovim, i.e. nvim
  2. See error

Screenshots

Error detected while processing BufWinEnter Autocommands for "*":                                                                                                                                                                          
Barbar detected an error while running. Barbar disabled itself :/ Include this in your report: .../.local/share/nvim/lazy/barbar.nvim/lua/barbar/icons.lua:72: attempt to concatenate local 'icon_hl' (a nil value)                        
stack traceback:                                                                                                                                                                                                                           
^I.../.local/share/nvim/lazy/barbar.nvim/lua/barbar/icons.lua:72: in function 'get_icon'                                                                                                                                                   
^I...cal/share/nvim/lazy/barbar.nvim/lua/barbar/ui/layout.lua:139: in function 'calculate_buffer_width'                                                                                                                                    
^I...cal/share/nvim/lazy/barbar.nvim/lua/barbar/ui/layout.lua:201: in function 'calculate_buffers_width'                                                                                                                                   
^I...cal/share/nvim/lazy/barbar.nvim/lua/barbar/ui/layout.lua:66: in function 'calculate'                                                                                                                                                  
^I...cal/share/nvim/lazy/barbar.nvim/lua/barbar/ui/render.lua:563: in function 'generate_tabline'                                                                                                                                          
^I...cal/share/nvim/lazy/barbar.nvim/lua/barbar/ui/render.lua:733: in function <...cal/share/nvim/lazy/barbar.nvim/lua/barbar/ui/render.lua:733>                                                                                           
^I[C]: in function 'xpcall'                                                                                                                                                                                                                
^I...cal/share/nvim/lazy/barbar.nvim/lua/barbar/ui/render.lua:732: in function 'update'                                                                                                                                                    
^I....local/share/nvim/lazy/barbar.nvim/lua/barbar/events.lua:130: in function <....local/share/nvim/lazy/barbar.nvim/lua/barbar/events.lua:130>                                                                                           
Error detected while processing BufEnter Autocommands for "*":                                                                                                                                                                             
Barbar detected an error while running. Barbar disabled itself :/ Include this in your report: .../.local/share/nvim/lazy/barbar.nvim/lua/barbar/icons.lua:72: attempt to concatenate local 'icon_hl' (a nil value)                        
stack traceback:                                                                                                                                                                                                                           
^I.../.local/share/nvim/lazy/barbar.nvim/lua/barbar/icons.lua:72: in function 'get_icon'                                                                                                                                                   
^I...cal/share/nvim/lazy/barbar.nvim/lua/barbar/ui/layout.lua:139: in function 'calculate_buffer_width'                                                                                                                                    
^I...cal/share/nvim/lazy/barbar.nvim/lua/barbar/ui/layout.lua:201: in function 'calculate_buffers_width'                                                                                                                                   
^I...cal/share/nvim/lazy/barbar.nvim/lua/barbar/ui/layout.lua:66: in function 'calculate'                                                                                                                                                  
^I...cal/share/nvim/lazy/barbar.nvim/lua/barbar/ui/render.lua:563: in function 'generate_tabline'                                                                                                                                          
^I...cal/share/nvim/lazy/barbar.nvim/lua/barbar/ui/render.lua:733: in function <...cal/share/nvim/lazy/barbar.nvim/lua/barbar/ui/render.lua:733>                                                                                           
^I[C]: in function 'xpcall'                  
^I...cal/share/nvim/lazy/barbar.nvim/lua/barbar/ui/render.lua:732: in function 'update'                                                                                                                                                    
^I....local/share/nvim/lazy/barbar.nvim/lua/barbar/events.lua:130: in function <....local/share/nvim/lazy/barbar.nvim/lua/barbar/events.lua:130>                                                                                           
Press ENTER or type command to continue                                                                                                                    

Informations Neovim version: 0.9.0

Iron-E commented 1 year ago

Seems astrovim has its own config for nvim-web-devicons, I'll see if that's interfering with it. For now you can disable file icons:

opts = {icons = {filetype = {enabled = false}}},
Iron-E commented 1 year ago

@eelcocramer can you check that #483 fixes this issue?

eelcocramer commented 1 year ago

@Iron-E unfortunately not.

eelcocramer commented 1 year ago

But disabling file icons works as a workaround.

edit: the file icon is also still shown on the buffer tabs. strike that, I was talking about an older window which was still open. Disabling removes the file type icon (as one might expect).

Iron-E commented 1 year ago

Alright, I think I fixed the PR. Tested it with AstroNvim this time

You might have to uninstall and re-install this plugin if lazy.nvim doesn't pick up the update (I ran into that issue while testing this)

Feel free to reopen if the issue persists!

eelcocramer commented 1 year ago

Thanks, works like a charm!