Skip to main content

Overview

Bufferline provides a VSCode-like tab interface for Neovim buffers, making it easy to visualize and navigate between open files. Plugin: bufferline.nvim Config File: lua/user/bufferline.lua

Features

  • Visual buffer tabs at the top of the window
  • Mouse support for clicking tabs
  • Integration with NvimTree file explorer
  • Custom icons and separators
  • Git status indicators
  • Modified file indicators

Configuration

Display Options

The bufferline is configured with these visual settings:
options = {
  numbers = "none",
  indicator = { style = "icon", icon = "▎"},
  buffer_close_icon = '',
  modified_icon = "●",
  close_icon = "",
  left_trunc_marker = "",
  right_trunc_marker = "",
  max_name_length = 30,
  max_prefix_length = 30,
  tab_size = 21,
  separator_style = "thin",
}

Mouse Actions

Bufferline supports mouse interactions:
Mouse ActionBehavior
Left ClickSwitch to buffer
Right ClickDelete buffer
Middle ClickNone (disabled)
close_command = "Bdelete! %d",
right_mouse_command = "Bdelete! %d",
left_mouse_command = "buffer %d",
middle_mouse_command = nil,

NvimTree Integration

Bufferline creates an offset when NvimTree is open:
offsets = { 
  { 
    filetype = "NvimTree", 
    text = "", 
    padding = 1 
  } 
},
This ensures buffer tabs don’t overlap with the file explorer.

Tab Behavior

show_buffer_icons = true,
show_buffer_close_icons = true,
show_close_icon = true,
show_tab_indicators = true,
persist_buffer_sort = true,
enforce_regular_tabs = true,
always_show_bufferline = true,

Diagnostics

Diagnostics display is disabled by default:
diagnostics = false, -- Set to "nvim_lsp" or "coc" to enable
diagnostics_update_in_insert = false,

Enable LSP Diagnostics

To show error/warning counts in buffer tabs:
diagnostics = "nvim_lsp",
diagnostics_indicator = function(count, level, diagnostics_dict, context)
  return "("..count..")"
end,

Highlight Scheme

Bufferline uses a custom color scheme that integrates with your theme:
highlights = {
  fill = {
    fg = { attribute = "fg", highlight = "Visual" },
    bg = { attribute = "bg", highlight = "TabLine" },
  },
  buffer_selected = {
    fg = { attribute = "fg", highlight = "Normal" },
    bg = { attribute = "bg", highlight = "Normal" },
  },
  -- ... more highlight groups ...
}
Key highlight groups:
  • fill - Background behind all tabs
  • buffer_selected - Currently active buffer
  • buffer_visible - Visible but not active buffer
  • buffer - Inactive buffers
  • modified - Buffers with unsaved changes
  • duplicate - Buffers with same name (underlined)

Customization

Change Separator Style

Available styles: "thin", "thick", or custom characters:
separator_style = "thick",
-- Or custom:
separator_style = { '|', '|' },

Add Buffer Numbers

Show buffer numbers in tabs:
numbers = "ordinal", -- "ordinal" | "buffer_id" | "both"

Custom Name Formatter

Modify how buffer names are displayed:
name_formatter = function(buf)
  -- Remove extension from markdown files
  if buf.name:match('%.md') then
    return vim.fn.fnamemodify(buf.name, ':t:r')
  end
end,

Filter Buffers

Hide specific buffers from the tabline:
custom_filter = function(buf_number)
  -- Filter out by filetype
  if vim.bo[buf_number].filetype ~= "qf" then
    return true
  end
  -- Filter out by name
  if vim.fn.bufname(buf_number) ~= "[No Name]" then
    return true
  end
end,

Custom Sort Function

sort_by = function(buffer_a, buffer_b)
  -- Sort by modification time
  return buffer_a.modified > buffer_b.modified
end
While bufferline provides visual tabs, navigate buffers using:
  • Standard Vim commands: :bnext, :bprevious
  • Telescope buffer picker: <leader>b
  • Mouse clicks on tabs
  • vim-bdelete - Used for closing buffers without closing windows
  • NvimTree - File explorer integration
  • Lualine - Complementary statusline

Build docs developers (and LLMs) love