From 0f588b826771f4843e28531cb503403a0785ae57 Mon Sep 17 00:00:00 2001 From: triethyl Date: Mon, 11 Aug 2025 22:12:38 -0400 Subject: neovim: fixed incline and improved buffer management --- pkgs/custom-neovim/config/lua/mappings.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pkgs/custom-neovim/config/lua/mappings.lua') diff --git a/pkgs/custom-neovim/config/lua/mappings.lua b/pkgs/custom-neovim/config/lua/mappings.lua index 9b2c188..569ad25 100644 --- a/pkgs/custom-neovim/config/lua/mappings.lua +++ b/pkgs/custom-neovim/config/lua/mappings.lua @@ -33,8 +33,18 @@ mapkey("n", "b", "Manage buffers", "") mapkey("n", "bb", "Go to next buffer", ":bn") mapkey("n", "bB", "Go to previous buffer", ":bp") mapkey("n", "bd", "Delete current buffer", ":bd") +mapkey("n", "bd", "Force delete current buffer", ":bd!") mapkey("n", "bp", "Open buffer picker", ":lua Snacks.picker.buffers()") mapkey("n", "bg", "Open buffer live grep picker", ":lua Snacks.picker.grep_buffers()") +mapkey("n", "bc", "Clear invisible buffers", function () + local bufinfos = vim.fn.getbufinfo({buflisted = 1}) + vim.tbl_map(function (bufinfo) + if bufinfo.changed == 0 and (not bufinfo.windows or #bufinfo.windows == 0) then + print(('Deleting buffer %d : %s'):format(bufinfo.bufnr, bufinfo.name)) + vim.api.nvim_buf_delete(bufinfo.bufnr, {force = false, unload = false}) + end + end, bufinfos) +end) -- Windows mapkey("n", "w", "Manage windows", "") -- cgit v1.2.3