nvim-tree / nvim-web-devicons

lua `fork` of vim-web-devicons for neovim
MIT License
2.1k stars 184 forks source link

`set_icon` fails if `variant` is not set #498

Closed igorgue closed 1 month ago

igorgue commented 1 month ago

I had this problem, probably an easy fix, but the latest variant feature broke set_icon if it's set to nil (unset), in my setup it fails like this:

Failed to source `/home/igor/.local/share/nvim/lazy/sonicpi.nvim/after/plugin/sonicpi.lua`

vim/_editor.lua:0: BufReadPost Autocommands for "*.sonicpi"..FileType Autocommands for "sonicpi"..script nvim_exec2() called at FileType Autocommands for "sonicpi":0../home/igor/.local/share/nvi
m/lazy/sonicpi.nvim/after/plugin/sonicpi.lua: Vim(source):E5113: Error while calling lua chunk: vim/shared.lua:0: after the second argument: expected table, got nil                              
stack traceback:                                                                                                                                                                                  
^I[C]: in function 'error'                                                                                                                                                                        
^Ivim/shared.lua: in function 'validate'                                                                                                                                                          
^Ivim/shared.lua: in function 'tbl_extend'                                                                                                                                                        
^I...re/nvim/lazy/nvim-web-devicons/lua/nvim-web-devicons.lua:574: in function 'set_icon'                                                                                                         
^I...al/share/nvim/lazy/sonicpi.nvim/after/plugin/sonicpi.lua:3: in main chunk                                                                                                                    
^I[C]: in function 'nvim_exec2'                                                                                                                                                                   
^Ivim/_editor.lua: in function 'cmd'                                                                                                                                                              
^I...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:503: in function <...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:502>                                                  
^I[C]: in function 'xpcall'                                                                                                                                                                       
^I.../.local/share/nvim/lazy/lazy.nvim/lua/lazy/core/util.lua:135: in function 'try'                                                                                                              
^I...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:502: in function 'source'                                                                                                           
^I...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:453: in function 'source_runtime'                                                                                                   
^I...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:424: in function 'packadd'                                                                                                          
^I...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:356: in function '_load'                                                                                                            
^I...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:197: in function 'load'                                                                                                             
^I...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:85: in function <...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:72>

If I add the variant to the opts of setup then it works.

alex-courtis commented 1 month ago

Apologies, improperly tested, fixed.

Please update to latest and advise whether the fix is correct.