47 lines
1.5 KiB
Lua
47 lines
1.5 KiB
Lua
return {
|
|
"akinsho/bufferline.nvim",
|
|
event = "VeryLazy",
|
|
keys = {
|
|
{ "<S-h>", "<cmd>BufferLineCyclePrev<cr>", desc = "Prev Buffer" },
|
|
{ "<S-l>", "<cmd>BufferLineCycleNext<cr>", desc = "Next Buffer" },
|
|
{ "[b", "<cmd>BufferLineCyclePrev<cr>", desc = "Prev Buffer" },
|
|
{ "]b", "<cmd>BufferLineCycleNext<cr>", desc = "Next Buffer" },
|
|
{ "[B", "<cmd>BufferLineMovePrev<cr>", desc = "Move buffer prev" },
|
|
{ "]B", "<cmd>BufferLineMoveNext<cr>", 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,
|
|
}
|