return { 'bufferline.nvim', event = 'DeferredUIEnter', keys = { { 'bp', 'BufferLineTogglePin', desc = 'toggle buffer pin', }, { 'bP', 'BufferLineGroupClose ungrouped', desc = 'delete non-pinned buffers', }, { 'br', 'BufferLineCloseRight', desc = 'delete buffers to the right', }, { 'bl', 'BufferLineCloseLeft', desc = 'delete buffers to the left', }, { '', 'BufferLineCyclePrev', desc = 'previous buffer' }, { '', 'BufferLineCycleNext', desc = 'next buffer' }, { '[b', 'BufferLineCyclePrev', desc = 'previous buffer' }, { ']b', 'BufferLineCycleNext', desc = 'next buffer' }, { '[B', 'BufferLineMovePrev', desc = 'move buffer left' }, { ']B', 'BufferLineMoveNext', desc = 'move buffer right' }, }, before = function() require('lz.n').trigger_load({ 'mini.icons', 'which-key.nvim' }) if vim.g.colors_name == 'rose-pine' then require('lz.n').trigger_load('rose-pine') end end, after = function() local opts = { options = { always_show_bufferline = true, close_command = function(n) Snacks.bufdelete(n) end, right_mouse_command = function(n) Snacks.bufdelete(n) end, diagnostics = 'nvim_lsp', diagnostics_indicator = function(_, _, diag) local icons = require('icons').diagnostics local ret = (diag.error and icons.Error .. diag.error .. ' ' or '') .. (diag.warning and icons.Warn .. diag.warning or '') return vim.trim(ret) end, offsets = { { filetype = 'neo-tree', text = 'Explorer', highlight = 'Directory', text_align = 'center', }, }, get_element_icon = function(elem) local icon, hl, _ = require('mini.icons').get('filetype', elem.filetype) return icon, hl end, }, } if vim.g.colors_name == 'rose-pine' then opts.highlights = require('rose-pine.plugins.bufferline') end require('bufferline').setup(opts) vim.api.nvim_create_autocmd({ 'BufAdd', 'BufDelete' }, { desc = 'Fix bufferline when restoring a session', callback = function() vim.schedule(function() pcall(nvim_bufferline) end) end, }) local colors = require('colors') local mkKey = MarleyVim.wkSpec(colors.buffers) require('which-key').add({ mkKey('bp', nil, ''), mkKey('bP', nil, '󰐄'), mkKey('br', nil, ''), mkKey('bl', nil, ''), mkKey('', nil, ''), mkKey('', nil, ''), mkKey('[b', nil, ''), mkKey(']b', nil, ''), mkKey('[B', nil, ''), mkKey(']B', nil, ''), }) end, }