return { "akinsho/bufferline.nvim", event = "VeryLazy", keys = { { "", "BufferLineCyclePrev", desc = "Prev Buffer" }, { "", "BufferLineCycleNext", desc = "Next Buffer" }, { "[b", "BufferLineCyclePrev", desc = "Prev Buffer" }, { "]b", "BufferLineCycleNext", desc = "Next Buffer" }, { "[B", "BufferLineMovePrev", desc = "Move buffer prev" }, { "]B", "BufferLineMoveNext", desc = "Move buffer next" }, }, opts = { options = { close_command = function(n) Snacks.bufdelete(n) end, right_mouse_command = function(n) Snacks.bufdelete(n) end, diagnostics = "nvim_lsp", always_show_bufferline = false, diagnostics_indicator = function(_, _, diag) local icons = CORE.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 = { { highlight = "Directory", text_align = "left", }, }, ---@param opts bufferline.IconFetcherOpts get_element_icon = function(opts) return CORE.icons.ft[opts.filetype] end, }, }, config = function(_, opts) require("bufferline").setup(opts) -- Fix bufferline when restoring a session vim.api.nvim_create_autocmd({ "BufAdd", "BufDelete" }, { callback = function() vim.schedule(function() pcall(nvim_bufferline) end) end, }) end, }