BibekBhusal0/bufstack.nvim

github github
utility
stars 2
issues 0
subscribers 0
forks 0
CREATED

2025-03-18

UPDATED

12 days ago


bufstack.nvim

A neovim plugin to cycle through recently used order and reopen recently closed buffers.

Features

  • Tracks recently used and recently closed buffers.
  • Lists tracked buffers in a menu (BufStackList, BufClosedList).
  • Navigates through tracked buffers (BufStackNext, BufStackPrev).
  • Reopens closed buffers (BufReopen).
  • Clears tracked and closed buffers (BufStackClear, BufClosedClear, BufClear).

Usage

Installation

Using lazy.nvim:

return {
    'BibekBhusal0/bufstack.nvim',
    dependencies = { 'MunifTanjim/nui.nvim' }, -- required if you want to use menu
    opts = { max_tracked = 16 }
}

Configuration

require('bufstack').setup({
  max_tracked = 16, -- Default: 16
})

Commands

  • BufStack: Tracks the current buffer.
  • BufStackNext: Navigates to the next tracked buffer.
  • BufStackPrev: Navigates to the previous tracked buffer.
  • BufStackList: Lists tracked buffers in a menu.
  • BufClosedList: Lists recently closed buffers in a menu.
  • BufReopen: Reopens the last closed buffer.
  • BufStackClear: Clears the list of tracked buffers.
  • BufClosedClear: Clears the list of closed buffers.
  • BufClear: Clears both tracked and closed buffers lists.

Key Mappings (Example)

vim.keymap.set('n', '<leader>bn', '<Cmd>BufStackNext<CR>')
vim.keymap.set('n', '<leader>bp', '<Cmd>BufStackPrev<CR>')
vim.keymap.set('n', '<leader>bl', '<Cmd>BufStackList<CR>')
vim.keymap.set('n', '<leader>br', '<Cmd>BufReopen<CR>')

Keymaps in Menu

Menu of tracked buffer and recently closed buffers can be opened with commands BufStackList and BufClosedList respectively.

Keymaps in the menu are:

  • j and arrow down for next item
  • k and arrow up for previous item
  • enter or space to select item
  • esc or q to close menu
  • d to remove item from list
  • D to remove all items from list
  • t to move item to the top of the list
  • x to close buffer (only in tracked buffer menu)

Dependencies

Credits

License

MIT