romgrk / barbar.nvim

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

Buffer order lost when using tiagovla/scope.nvim #556

Closed Iron-E closed 6 months ago

Iron-E commented 6 months ago

It seems to be an interaction between tiagovla/scope.nvim and barbar.nvim.

From @alexconst in https://github.com/romgrk/barbar.nvim/issues/555#issuecomment-2007030379:

scope.nvim does expose several hooks for tab enter and tabe leave, so maybe fixing this is feasible.

Does barbar.nvim exposes any way to get or set the buffer order? I take it it's using its own variables to track it because :ls and vim.api.nvim_list_bufs() always shows the same buffer order.

For reference sake, here is my minimal.lua which reproduces the issue:

local data_dir = vim.fn.stdpath 'data'
local plugin_dir = data_dir .. '/lazy/'

vim.opt.rtp:prepend { plugin_dir .. 'barbar.nvim' }
vim.g.barbar_auto_setup = false
require('barbar').setup {
    icons = {
        filetype = { enabled = false },
    },
}

-- https://github.com/tiagovla/scope.nvim
vim.opt.rtp:prepend { plugin_dir .. 'scope.nvim' }
require("scope").setup({})

To reproduce:

  1. nvim --clean -u minimal.lua aaa bbb ccc ddd eee
  2. reorder some buffers
  3. open new tab :tabe foo
  4. go back to first tab
  5. see that your custom buffer ordering has been lost
Iron-E commented 6 months ago

scope.nvim does expose several hooks for tab enter and tabe leave, so maybe fixing this is feasible.

Good to know, I'll take a look at those.

Does barbar.nvim exposes any way to get or set the buffer order?

The only means to set the buffer order currently is :BufferMoveNext and :BufferMovePrevious. We don't provide a way to get the buffer order (IIRC), though I don't see why we couldn't provide an :ls which respects buffer order (:BufferList?).

I take it it's using its own variables to track [buffer order] because :ls and vim.api.nvim_list_bufs() always shows the same buffer order.

The buffer order is currently located here (the order of all buffers) and here (the order of all buffers configured to be visible in the tabline).

Iron-E commented 6 months ago

I can reproduce the issue