nvim/nvim-old/lua/plugins/bufferline.lua

65 lines
2.7 KiB
Lua
Executable File

return {
-- tab line
"akinsho/bufferline.nvim",
version = "*",
dependencies = "nvim-tree/nvim-web-devicons",
config = function()
local bufferline = require("bufferline")
bufferline.setup({
options = {
mode = "buffers",
show_buffer_close_icons = false,
middle_mouse_command = "bdelete! %d",
indicator = { style = "underline" },
offsets = {
{
filetype = "NvimTree",
text = " ",
text_align = "center",
separator = true,
},
},
separator_style = { " ", " " },
diagnostics = "nvim_lsp",
diagnostics_indicator = function(count, level, diagnostics_dict, context)
local icon = level:match("error") and "󰅚 " or "󰀪 "
return icon .. count
end,
},
})
local opts = { silent = true }
-- go to buffer
opts.desc = "go to buffer 1"
vim.keymap.set("n", "g1", "<Cmd>BufferLineGoToBuffer 1<CR>", opts)
opts.desc = "go to buffer 2"
vim.keymap.set("n", "g2", "<Cmd>BufferLineGoToBuffer 2<CR>", opts)
opts.desc = "go to buffer 3"
vim.keymap.set("n", "g3", "<Cmd>BufferLineGoToBuffer 3<CR>", opts)
opts.desc = "go to buffer 4"
vim.keymap.set("n", "g4", "<Cmd>BufferLineGoToBuffer 4<CR>", opts)
opts.desc = "go to buffer 5"
vim.keymap.set("n", "g5", "<Cmd>BufferLineGoToBuffer 5<CR>", opts)
opts.desc = "go to buffer 6"
vim.keymap.set("n", "g6", "<Cmd>BufferLineGoToBuffer 6<CR>", opts)
opts.desc = "go to buffer 7"
vim.keymap.set("n", "g7", "<Cmd>BufferLineGoToBuffer 7<CR>", opts)
opts.desc = "go to buffer 8"
vim.keymap.set("n", "g8", "<Cmd>BufferLineGoToBuffer 8<CR>", opts)
opts.desc = "go to buffer 9"
vim.keymap.set("n", "g9", "<Cmd>BufferLineGoToBuffer 9<CR>", opts)
opts.desc = "go to buffer 10"
vim.keymap.set("n", "g0", "<Cmd>BufferLineGoToBuffer 10<CR>", opts)
opts.desc = nil
-- cycle between buffers
vim.keymap.set("n", "J", "<cmd>BufferLineCyclePrev<CR>", opts)
vim.keymap.set("n", "K", "<cmd>BufferLineCycleNext<CR>", opts)
-- move buffers
vim.keymap.set("n", "<C-S-J>", "<cmd>BufferLineMovePrev<CR>", opts)
vim.keymap.set("n", "<C-S-K>", "<cmd>BufferLineMoveNext<CR>", opts)
-- go to previous buffer
vim.keymap.set({ "n", "i" }, "<C-Tab>", "<cmd>b#<CR>", opts)
end,
}