rebelot/heirline.nvim

Issues with persisted plugin

Closed this issue ยท 4 comments

Hi ๐Ÿ‘‹,

I'm trying to setup my own nvim config. I used astronvim as the base config.
I tried to add the persisted.nvim plugin.
To help me manage my sessions, where the config looks something like this https://github.com/hmajid2301/dotfiles/blob/tmux-status/nvim/lua/user/plugins/user.lua#L53-L59:

  {
    "olimorris/persisted.nvim",
    event = "VimEnter",
    priority = 500,
    opts = {
      autoload = true
    }
  }

However when ever I try to open nvim I know get this error:

"nvim/lua/user/plugins/user.lua" 60L, 1271B
Error detected while processing VimEnter Autocommands for "*":
Error executing lua callback: /home/haseeb/.config/nvim/lua/astronvim/utils/status.lua:108: Invalid buffer id: 1
stack traceback:
        [C]: in function '__index'
        /home/haseeb/.config/nvim/lua/astronvim/utils/status.lua:108: in function </home/haseeb/.config/nvim/lua/astronvim/utils/status.lua:108>
        /home/haseeb/.config/nvim/lua/astronvim/utils/status.lua:813: in function 'callback'
        ...ocal/share/nvim/lazy/heirline.nvim/lua/heirline/init.lua:41: in function <...ocal/share/nvim/lazy/heirline.nvim/lua/heirline/init.lua:28>

It seems to be caused by https://github.com/hmajid2301/dotfiles/blob/main/nvim/lua/plugins/heirline.lua#L9-L12. When I comment this code out the error goes away.

Im very new to nvim and lua, so any help would be greatly appreciated.

  "rebelot/heirline.nvim",
  event = "BufEnter",
  opts = function()
    local status = require "astronvim.utils.status"
    return {
      opts = {
        disable_winbar_cb = function(args)
          return status.condition.buffer_matches({
            buftype = { "terminal", "prompt", "nofile", "help", "quickfix" },
            filetype = { "NvimTree", "neo%-tree", "dashboard", "Outline", "aerial" },
          }, args.buf)
        end,
      },
// ....
}

```

I have no idea why this could happen.. in the meantime, you can guard the callback using something like this:

  "rebelot/heirline.nvim",
  event = "BufEnter",
  opts = function()
    local status = require "astronvim.utils.status"
    return {
      opts = {
        disable_winbar_cb = function(args)
          if not vim.api.nvim_buf_is_valid(args.buf) then return end
          return status.condition.buffer_matches({
            buftype = { "terminal", "prompt", "nofile", "help", "quickfix" },
            filetype = { "NvimTree", "neo%-tree", "dashboard", "Outline", "aerial" },
          }, args.buf)
        end,
      },
// ....
}

I tried to do it like this; https://gitlab.com/hmajid2301/dotfiles/-/blob/tmux-status-bar/nvim/lua/user/plugins/heirline.lua#L80-88

        opts.disable_winbar_cb = function(args)
            if not vim.api.nvim_buf_is_valid(args.buf) then return end
            return status.condition.buffer_matches({
                buftype = {"terminal", "prompt", "nofile", "help", "quickfix"},
                filetype = {
                    "NvimTree", "neo%-tree", "dashboard", "Outline", "aerial"
                }
            }, args.buf)
        end

And I'm still getting the same error

May I ask how you solved the issue?

I stopped using astronvim and moved to lazyvim. Which doesnt user either of these plugins. So didnt really solve it ๐Ÿ˜“