romgrk / barbar.nvim

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

Question: Compare with bufferline.nvim? #576

Closed linrongbin16 closed 1 month ago

linrongbin16 commented 1 month ago

hi, what's the difference between this plugin and bufferline.nvim? Since I feel they look quite close to each other?

Actually I have been use barbar.nvim several months (maybe over a year, I don't remember), then I switched to bufferline.nvim. the differences I could tell are:

  1. barbar seems doesn't support different separator styling, while bufferline provide: slant, padded_slant, padded_slope, etc. Update: I found barbar also support some separator stylings now.
  2. barbar always render file type icon with the icon color from nvim-web-devicons library, while bufferline will make it grey for those in-active buffers/tabs. Update: I found barbar also make in-active buffers file type icon color to grey now.
  3. barbar embed the vim-bbye plugin (known as the Bdelete and Bwipeout user command), which helps delete/wipeout a buffer without break up user's window layout. bufferline doesn't have such commands, so user have to look for other plugins like bufdelete.nvim or vim-bbye.
  4. Some different behaviors between goto (or navigate) commands provided by these two plugins.
  5. barbar seems doesn't have the BufferLineCycleNext and BufferLineCyclePrev commands provided by bufferline.

Any other differences?


Update: there're two differences I have to mention, because they're the reasons I go back to barbar:

  1. barbar can auto-sizing tabs width, which is really a feature I'm missing when I use bufferline, my eyes just feel more comfortable when there's few tabs and the width becomes wider.

    image image
  2. When there're too many buffers opened, barbar renders the two tabs on left and right side partially and fill Neovim's tabline. While bufferline will left extra spaces, I personally prefer barbar because it provides more info (see picture below).

    image image
sinkr commented 1 month ago

Your question helped me and maybe it will help you, too (I didn't know about bufferline 'til a few minutes ago).

I have been bouncing between barbar and cokeline (and their respective GitHub communities) for several weeks now, trying to get hover, tab drag, and LSP symbols in the tabs, all to no avail.

After minimal searching (30-45 minutes vs. hours and weeks), I was able to get bufferline to do what I could not get these other 2 to do.

YMMV.

romgrk commented 1 month ago

Pretty animations. Cool name.

I don't use fancy features like LSP symbols and mouse stuff, so it has gotten less attention than bufferline on that front. Bufferline is a good plugin, I'd probably use it if I didn't have barbar. But I want my pretty animations.

sinkr commented 1 month ago

I consistently got this within LazyVim when trying to drag and reorder tabs:

Error executing  vim.on_key Lua callback: vim/_editor.lua:0: Error executing 'on_key' with ns_ids '20'
    Messages: ....local/share/nvim/lazy/barbar.nvim/lua/barbar/events.lua:108: attempt to index field 'buffers' (a nil value)
stack traceback:
    [C]: in function 'error'
    vim/_editor.lua: in function <vim/_editor.lua:0>  

No matter how simple the plugin config was, this won't work for me with most plugins in vim 0.10.0 nightly or 0.9.5.

Iron-E commented 1 month ago

Hopefully I can provide additional clarification:

  1. barbar seems doesn't support different separator styling, while bufferline provide: slant, padded_slant, padded_slope, etc. - Updated: I found barbar also support some separator stylings now.

barbar does provide different separator styling, and we have several layers of granularity here:

-- Use a preset to achieve commonly-desired looks
require('barbar').setup { icons = { preset = 'slanted' } }

-- Customize appearance of icons individually
require('barbar').setup {
    -- the default separators
    separator = { left = '/', right = '\\', },

    -- the default separators of modified and pinned buffers
    modified = { --[[ separator = { … } ]] },
    pinned = { --[[ separator = { … } ]] },

    -- the separators for alternate, current, inactive, and visible buffers
    alternate = { --[[ modified = { separator = { … } }, pinned = { separator = { … } }, separator = { … } ]] },
    current = { --[[ modified = { separator = { … } }, pinned = { separator = { … } }, separator = { … }, ]] },
    inactive = { --[[ modified = { separator = { … } }, pinned = { separator = { … } }, separator = { … }, ]] },
    visible = { --[[ modified = { separator = { … } }, pinned = { separator = { … } }, separator = { … }, ]] },
}
  1. barbar always render file type icon with the icon color from nvim-web-devicons library, while bufferline will make it grey/dim for those in-active buffers/tabs (but bufferline allow user customize it).

This is also customizable in barbar, for example:

require('barbar').setup {
    icons = {
        filetype = {
            custom_colors = true,
            enabled = true,
        },
    },
}

-- choose the icon color for current, alternate, visible, and inactive buffers
vim.api.nvim_set_hl(0, 'BufferAlternateIcon', { … })
vim.api.nvim_set_hl(0, 'BufferCurrentIcon', { … })
vim.api.nvim_set_hl(0, 'BufferInactiveIcon', { … })
vim.api.nvim_set_hl(0, 'BufferVisibleIcon', { … })

I have been bouncing between barbar and cokeline (and their respective GitHub communities) for several weeks now, trying to get hover, tab drag, and LSP symbols in the tabs, all to no avail.

barbar.nvim does not support tab hover currently, though I'd be glad to help get any other features working if there are problems :)


I consistently got this within LazyVim when trying to drag and reorder tabs:

Seems there has been a regression since that was implemented, will have a fix shortly.

Edit: seems to have regressed in #573

Iron-E commented 1 month ago

Merged a PR which should fix the issue reported in https://github.com/romgrk/barbar.nvim/issues/576#issuecomment-2110057105

sinkr commented 1 month ago

Works beautifully now, thank you!