Skip to content

iAverages/auto-buffer-close.nvim

Repository files navigation

auto-buffer-close.nvim

A simple Neovim plugin that automatically closes buffers when you leave them if they haven't been modified since opening.

Features

  • Automatically closes unmodified buffers when you switch away from them

Installation

Using lazy.nvim:

{
    "iAverages/auto-buffer-close.nvim",
    opts = {}
}

Configuration

The plugin can be configured with the following options:

require("auto-buffer-close").setup({
    ignore_blank_lines = true, -- Whether to ignore blank lines when comparing buffer content
})

Usage

Simply call the setup function in your Neovim configuration:

require("auto-buffer-close").setup()

How it works

  1. When you enter a buffer for the first time, the plugin stores its content
  2. When you leave the buffer, it compares the current content with the stored content
  3. If the content is unchanged, the buffer is automatically closed
  4. Special buffers (terminals, help, etc.) and unnamed buffers are ignored

Why?

In VS Code, when you open a file from the file explorer or through quick open, it opens in "preview mode" - shown with an italic filename in the tab. If you navigate away without making any changes, the tab automatically closes to keep your workspace clean. This plugin brings similar behavior to Neovim by automatically closing unmodified buffers when you leave them. Mostly useful if you have a bufferline plugin to display open buffers.

This helps maintain a cleaner buffer list and reduces the mental overhead of managing dozens of open buffers that you only briefly viewed.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •