mini.bufremove documentation
Generated from the main
branch of ‘mini.nvim’
mini.bufremove Remove buffers
MIT License Copyright (c) 2021 Evgeni Chasnovski
Module
Features:
- Unshow, delete, and wipeout buffer while saving window layout (opposite to builtin Neovim’s commands).
Setup
This module doesn’t need setup, but it can be done to improve usability. Setup with require('mini.bufremove').setup({})
(replace {}
with your config
table). It will create global Lua table MiniBufremove
which you can use for scripting or manually (with :lua MiniBufremove.*
).
See MiniBufremove.config for config
structure and default values.
This module doesn’t have runtime options, so using vim.b.minibufremove_config
will have no effect here.
To stop module from showing non-error feedback, set config.silent = true
.
Notes
Which buffer to show in window(s) after its current buffer is removed is decided by the algorithm:
If alternate buffer (see CTRL-^) is listed (see buflisted()), use it.
If previous listed buffer (see :bprevious) is different, use it.
Otherwise create a new one with
nvim_create_buf(true, false)
and use it.
Disabling
To disable core functionality, set vim.g.minibufremove_disable
(globally) or vim.b.minibufremove_disable
(for a buffer) to true
. Considering high number of different scenarios and customization intentions, writing exact rules for disabling module’s functionality is left to user. See mini.nvim-disabling-recipes for common recipes.
setup()
MiniBufremove.setup
({config})
Module setup
Parameters
{config} (table|nil)
Module config table. See MiniBufremove.config.
Usage
require('mini.bufremove').setup() -- use default config
-- OR
require('mini.bufremove').setup({}) -- replace {} with your config table
config
MiniBufremove.config
Defaults
MiniBufremove.config = {
-- Whether to disable showing non-error feedback
silent = false,
}
delete()
MiniBufremove.delete
({buf_id}, {force})
Delete buffer buf_id
with :bdelete after unshowing it
Parameters
{buf_id} (number|nil)
Buffer identifier (see bufnr()) to use. Default: 0 for current.
{force} (boolean|nil)
Whether to ignore unsaved changes (using !
version of command). If false
, calling with unsaved changes will prompt confirm dialog. Default: false
.
Return
(boolean|nil)
Whether operation was successful. If nil
, no operation was done.
wipeout()
MiniBufremove.wipeout
({buf_id}, {force})
Wipeout buffer buf_id
with :bwipeout after unshowing it
Parameters
{buf_id} (number|nil)
Buffer identifier (see bufnr()) to use. Default: 0 for current.
{force} (boolean|nil)
Whether to ignore unsaved changes (using !
version of command). If false
, calling with unsaved changes will prompt confirm dialog. Default: false
.
Return
(boolean|nil)
Whether operation was successful. If nil
, no operation was done.
unshow()
MiniBufremove.unshow
({buf_id})
Stop showing buffer buf_id
in all windows
Parameters
{buf_id} (number|nil)
Buffer identifier (see bufnr()) to use. Default: 0 for current.
Return
(boolean|nil)
Whether operation was successful. If nil
, no operation was done.
unshow_in_window()
MiniBufremove.unshow_in_window
({win_id})
Stop showing current buffer of window win_id
Notes:
- If
win_id
represents cmdline-window, this function will close it.
Parameters
{win_id} (number|nil)
Window identifier (see win_getid()) to use. Default: 0 for current.
Return
(boolean|nil)
Whether operation was successful. If nil
, no operation was done.