From 213a1a61e415fada4e2da36ee0772f31b62acbae Mon Sep 17 00:00:00 2001 From: Michal Date: Wed, 26 Mar 2025 16:39:00 +0100 Subject: [PATCH] Add bufferline --- init.lua | 1 + lua/custom/plugins/bufferline.lua | 81 +++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 lua/custom/plugins/bufferline.lua diff --git a/init.lua b/init.lua index 948349ba..461911c5 100644 --- a/init.lua +++ b/init.lua @@ -998,6 +998,7 @@ require('lazy').setup({ -- require 'kickstart.plugins.lint', -- require 'kickstart.plugins.autopairs', require 'kickstart.plugins.neo-tree', + require 'custom.plugins.bufferline', -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` diff --git a/lua/custom/plugins/bufferline.lua b/lua/custom/plugins/bufferline.lua new file mode 100644 index 00000000..968096de --- /dev/null +++ b/lua/custom/plugins/bufferline.lua @@ -0,0 +1,81 @@ +return { + 'akinsho/bufferline.nvim', + dependencies = { + 'moll/vim-bbye', + 'nvim-tree/nvim-web-devicons', + }, + config = function() + -- vim.opt.linespace = 8 + + require('bufferline').setup { + options = { + mode = 'buffers', -- set to "tabs" to only show tabpages instead + themable = true, -- allows highlight groups to be overriden i.e. sets highlights as default + numbers = 'none', -- | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string, + close_command = 'Bdelete! %d', -- can be a string | function, see "Mouse actions" + right_mouse_command = 'Bdelete! %d', -- can be a string | function, see "Mouse actions" + left_mouse_command = 'buffer %d', -- can be a string | function, see "Mouse actions" + middle_mouse_command = nil, -- can be a string | function, see "Mouse actions" + -- buffer_close_icon = '󰅖', + buffer_close_icon = '✗', + -- buffer_close_icon = '✕', + close_icon = '', + path_components = 1, -- Show only the file name without the directory + modified_icon = '●', + left_trunc_marker = '', + right_trunc_marker = '', + max_name_length = 30, + max_prefix_length = 30, -- prefix used when a buffer is de-duplicated + tab_size = 21, + diagnostics = false, + diagnostics_update_in_insert = false, + color_icons = true, + show_buffer_icons = true, + show_buffer_close_icons = true, + show_close_icon = true, + persist_buffer_sort = true, -- whether or not custom sorted buffers should persist + separator_style = { '│', '│' }, -- | "thick" | "thin" | { 'any', 'any' }, + enforce_regular_tabs = true, + always_show_bufferline = true, + show_tab_indicators = false, + indicator = { + -- icon = '▎', -- this should be omitted if indicator style is not 'icon' + style = 'none', -- Options: 'icon', 'underline', 'none' + }, + icon_pinned = '󰐃', + minimum_padding = 1, + maximum_padding = 5, + maximum_length = 15, + sort_by = 'insert_at_end', + }, + highlights = { + separator = { + fg = '#434C5E', + }, + buffer_selected = { + bold = true, + italic = false, + }, + -- separator_selected = {}, + -- tab_selected = {}, + -- background = {}, + -- indicator_selected = {}, + -- fill = {}, + }, + } + + -- Keymaps + local opts = { noremap = true, silent = true, desc = 'Go to Buffer' } + -- vim.keymap.set("n", "", "BufferLineCycleNext", {}) + -- vim.keymap.set("n", "", "BufferLineCyclePrev", {}) + -- vim.keymap.set('n', '1', "lua require('bufferline').go_to_buffer(1)", opts) + -- vim.keymap.set('n', '2', "lua require('bufferline').go_to_buffer(2)", opts) + -- vim.keymap.set('n', '3', "lua require('bufferline').go_to_buffer(3)", opts) + -- vim.keymap.set('n', '4', "lua require('bufferline').go_to_buffer(4)", opts) + -- vim.keymap.set('n', '5', "lua require('bufferline').go_to_buffer(5)", opts) + -- vim.keymap.set('n', '6', "lua require('bufferline').go_to_buffer(6)", opts) + -- vim.keymap.set('n', '7', "lua require('bufferline').go_to_buffer(7)", opts) + -- vim.keymap.set('n', '8', "lua require('bufferline').go_to_buffer(8)", opts) + -- vim.keymap.set('n', '9', "lua require('bufferline').go_to_buffer(9)", opts) + end, +}