romgrk / barbar.nvim

The neovim tabline plugin.
2.2k stars 81 forks source link

Startup error: attempt to index a boolean value #417

Closed gabriel-sevecek closed 1 year ago

gabriel-sevecek commented 1 year ago

Description

A clear and concise description of what the bug is.

Getting the following error on startup:

local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:438: Vim(source):E5113: Error while calling lua chunk: ...iel/.local/share/nvim/lazy/barbar.nvim/plugin/barbar.lua:18: attempt to index a boolean value 

To Reproduce

init.lua:

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
    {'romgrk/barbar.nvim',
      event = "BufEnter",
      dependencies = "nvim-tree/nvim-web-devicons",
      opts = {},
    };

Informations Neovim version: 0.8.3

romgrk commented 1 year ago

Can't reproduce on the latest master with the provided config (which contains a typo at the end, btw). Can you give us more details? Would you be able to run this: :lua print(vim.inspect(require'bufferline'))?

Iron-E commented 1 year ago

Is that the full error? If the stacktrace is longer that would help

gabriel-sevecek commented 1 year ago

Hey, thanks for the replies.

Running :lua print(vim.inspect(require'bufferline')) prints true.

The whole stack:

Failed to source `/home/gabriel/.local/share/nvim/lazy/barbar.nvim/plugin/barbar.lua`                                                                         
...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:438: Vim(source):E5113: Error while calling lua chunk: ...iel/.local/share/nvim/lazy/barbar.nvim/plugin/barb
ar.lua:18: attempt to index a boolean value
stack traceback:
^I...iel/.local/share/nvim/lazy/barbar.nvim/plugin/barbar.lua:18: in main chunk
^I[C]: in function 'cmd'
^I...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:438: in function <...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:437>
^I[C]: in function 'xpcall'
^I.../.local/share/nvim/lazy/lazy.nvim/lua/lazy/core/util.lua:110: in function 'try'
^I...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:437: in function 'source'
^I...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:396: in function 'source_runtime'
^I...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:364: in function 'packadd'
^I...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:304: in function '_load'
^I...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:180: in function 'load'
^I...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:33: in function <...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:26>
Failed to run `config` for barbar.nvim
...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:330: attempt to index a boolean value

Neovim version:

❯ nvim --version
NVIM v0.8.3
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by nixbld

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/nix/store/ag8ka4jppvcrcdpzgs7hrwjh6zr15581-neovim-unwrapped-master/share/nvim
"

Run :checkhealth for more info
Iron-E commented 1 year ago

I can't reproduce either. Some things to try:

gabriel-sevecek commented 1 year ago

I get the same error with latest neovim from master :smiling_face_with_tear:

Iron-E commented 1 year ago

If you can get it to repro with a minimal config like this:

nvim --clean 
     --cmd 'set rtp+=~/.local/share/nvim/site/pack/packer/start/barbar.nvim' 
     --cmd 'set rtp+=~/.local/share/nvim/site/pack/packer/start/nvim-web-devicons' 
     --cmd 'lua require"barbar".setup()'

I can probably be of more help. Otherwise, it's likely an issue on the config/lazy side

(Change the paths to wherever barbar and nvim-web-devicons are installed)

gabriel-sevecek commented 1 year ago

That works, no error. Seems like it's some local or lazy issue. Thanks for helping with the troubleshooting.

gabriel-sevecek commented 1 year ago

So, I actually had a file like this ~/.config/nvim/lua/barbar.nvim :facepalm: It contains which-key config for barbar, I guess that was being loaded instead of the actual barbar.nvim. It didn't cause any issues, until it did (I guess it stopped working after an update).

Sorry for wasting your time and thanks again.

Iron-E commented 1 year ago

Ah, that'd do it. Top-level modules (e.g. lua/foo.lua) that have the same name of a plugin (e.g. nvim-foo or foo.nvim) can cause clashes in the loader.

If you didn't already find another solution, you can move that file to lua/plugin/barbar.lua (or lua/<your_username>/barbar.lua) and it will work (of course, update anything that references the old path)