Skip to content

wsdjeg/bufdel.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bufdel.nvim

bufdel.nvim is a neovim plugin that helps you delete buffers without changing windows layout.

Installation

Using nvim-plug

require('plug').add({
    'wsdjeg/bufdel.nvim',
})

Using luarocks

luarocks install bufdel.nvim

Usage

  1. delete a specific buffer:
require("bufdel").delete(2, { wipe = true })
  1. delete more than one buffers:
require("bufdel").delete({ 2, 3, 5 }, { wipe = true })
  1. delete buffers with filter function:
require("bufdel").delete(function(buf)
    return not vim.bo[buf]modified and vim.bo[buf].buflisted
end, { wipe = true })

User Commands

bufdel.nvim also provides two user commands :Bdelete and :Bwipeout, which is just same as :delete and :bwipeout, but these user commands will not change the windows layout.

User Autocmds

bufdel.nvim triggers two user autocmds when delete a buffer, User BufDelPro and User BufDelPost. here is an example to handled these events:

local mygroup = vim.api.nvim_create_augroup("bufdel_custom", { clear = true })
vim.api.nvim_create_autocmd({ "User" }, {
	group = mygroup,
	pattern = "BufDelPro",
	callback = function(ev)
        --- the deleted buffer number is saved in ev.data.buf
    end,
})
vim.api.nvim_create_autocmd({ "User" }, {
	group = mygroup,
	pattern = "BufDelPost",
	callback = function(ev)
        --- the deleted buffer number is saved in ev.data.buf
    end,
})

The User BufDelPost event will not be triggered if failed to delete buffer.

Credits

Self-Promotion

Like this plugin? Star the repository on GitHub.

Love this plugin? Follow me on GitHub.

License

This project is licensed under the GPL-3.0 License.

About

delete buffers without changing windows layout

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant