akinsho / bufferline.nvim

A snazzy bufferline for Neovim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: (UNKNOWN PLUGIN): Error executing lua: attempt to call a number value

pwnalone opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

image

Related Issues

This issue has been reported before three other times that I am aware of, typically in relation to the nvim-tree plugin; however, the previous issue authors failed to provide a minimal configuration to help troubleshoot the issue. Furthermore, I have determined that this issue does not relate to nvim-tree or any other file explorer. Please see below for a minimal configuration.

Steps to Reproduce

  1. Place the minimal configuration at ~/.config/nvim/init.lua.
  2. Start nvim to install the 3 relevant plugins.
  3. Close and reopen nvim.
  4. Execute :h g and then :h h (or anything else that opens up a different help document).
  5. Repeat steps 3-4 until you observe the error, above.
Dockerfile

Here is a Dockerfile to easily setup a clean environment with the latest stable release of Neovim installed.

FROM ubuntu:latest

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install -y build-essential curl git tar
RUN curl -sL https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz \
    | tar -zxf - -C /usr/local --strip-components=1

CMD /bin/bash
Build
docker build -t neovim .
Start
docker run --rm -it -v $PWD:/root/.config/nvim -w /root/.config/nvim neovim

What did you expect to happen?

There should not be an error.

Config

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',
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require('lazy').setup({
  {
    'akinsho/bufferline.nvim',
    version = '*',
    dependencies = { 'nvim-tree/nvim-web-devicons' },
    event = { 'VimEnter' },
    init = function()
      vim.o.termguicolors = true
    end,
    opts = {},
  },
  {
    'folke/tokyonight.nvim',
    priority = 1000,
    config = function()
      vim.cmd.colorscheme('tokyonight-night')
    end,
  },
  {
    'nvim-treesitter/nvim-treesitter',
    build = ':TSUpdate',
    event = { 'VimEnter' },
    config = function(_, opts)
      require('nvim-treesitter.configs').setup(opts)
    end,
    opts = {
      ensure_installed = { 'lua', 'vim', 'vimdoc' },
      highlight = { enable = true },
    },
  },
})

Additional Information

So far, I've only been able to narrow down the source of the issue to the interaction between 3 different plugins – bufferline (i.e. this plugin), nvim-treesitter, and tokyonight.

I'm opening this issue here because I believe that it is most likely that the problem is in this plugin and not the others. My reasoning for this is that the error, shown in the above screenshot, has only reported here and not in the other 2 plugins, causing me to assume that others have not experienced this issue without bufferline.

Because the issue does not always result in an error, it seems that it is likely to be a race condition.

Interestingly, I have only observed this issue with the Tokyonight colorscheme, so maybe its related to some new/unique features that this colorscheme is using that the others are not, and which bufferline does not properly account for (just a wild guess).

I have tested the minimal config with these additional colorschemes and have observed no issues.

  {
    'rebelot/kanagawa.nvim',
    priority = 1000,
    config = function()
      vim.cmd.colorscheme('kanagawa-wave')
    end,
  },
  {
    'catppuccin/nvim',
    name = 'catppuccin',
    priority = 1000,
    config = function()
      vim.cmd.colorscheme('catppuccin-mocha')
    end,
  },
  {
    'morhetz/gruvbox',
    priority = 1000,
    config = function()
      vim.cmd.colorscheme('gruvbox')
    end,
  },
  {
    'bluz71/vim-nightfly-colors',
    priority = 1000,
    config = function()
      vim.cmd.colorscheme('nightfly')
    end,
  },
  {
    'dracula/vim',
    name = 'dracula',
    priority = 1000,
    config = function()
      vim.cmd.colorscheme('dracula')
    end,
  },

commit

No response

UPDATE:

It seems that this plugin works with Tokyonight's v2.9.0 version, but not v3.0.0 or v3.1.0. The issue can still be observed in v2.9.0, all the way back to the initial v1.0.0 release.

UPDATE:

I tested multiple versions for each of bufferline, tokyonight, and nvim-treesitter, going back to their respective initial releases while keeping the other two plugins at their most recent versions. Furthermore, I tried simultaneously decreasing the versions of all three plugins, choosing versions for each that were released around approximately the same time, going back to late 2022.

For all combinations I tried, I was unable to find any where the error could not be observed.

commented

@pwnalone thanks for digging in and taking the time to document this issue. As you say I've never encountered this as I don't use Tokyo night and never have so it's not immediately clear what this interaction is. One possible cause could be how that plugin interacts with this. I think there might be some module of this plugin's that that theme is using that this plugin might not be expecting or it's interacting in some way.

Tbh I'm not likely to be able to dig into this anytime soon, anyone else who wants to take a stab should please do or just document more stuff in here. As always community contributions re a fix would be massively appreciated as I'm definitely not in a place where I can dedicate much free time to these issue.

@akinsho Thanks for getting back to me so quickly on this. I have switched to a different colorscheme as a temporary fix, but will try to troubleshoot this issue some more if I find the time. If I discover the source of the issue, I'll open a PR. In any case, I'll keep documenting any relevant information here.

I am also experiencing this issue. I am using sainnhe/sonokai if that's helpful but I was able to produce it with nvim's default colorscheme.

At one point I thought it was folke/todo-comments.nvim because after adding event='VimEnter' I was able to avoid the error. I made a bug there but wasn't able to produce it using only todo-comments so I closed it. folke/todo-comments.nvim#254

Here is a bare bones version of my init.lua that will also produce the error.

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/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", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    "nvim-tree/nvim-tree.lua",
    config = true,
    dependencies = { "nvim-tree/nvim-web-devicons" }
  },
  {
    'akinsho/bufferline.nvim',
    config = true,
    version = "*",
    dependencies = 'nvim-tree/nvim-web-devicons',
  },
  'neovim/nvim-lspconfig',
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

The problem only occurs when you open nvim using the directory reference in question Ex: nvim .

The bug did not occur when calling only nvim in the directory in question.

My config

require("bufferline").setup
{
  options = 
   {
      mode = "buffers",
      close_icon = '',
      separetor_style = 'thin',
      offsets =
      {
	{
           filetype = "NvimTree",
           text = "File Explorer",
	   highlight = "Directory",
	   separetor = true,
           padding = 1
	},
      },
    }
  }