diff options
| author | triethyl <triethylammonium@pm.me> | 2025-08-11 22:12:38 -0400 |
|---|---|---|
| committer | triethyl <triethylammonium@pm.me> | 2025-08-11 22:12:38 -0400 |
| commit | 0f588b826771f4843e28531cb503403a0785ae57 (patch) | |
| tree | 17fac73316d5b970e37bdb7f4485816d0905461a /pkgs/custom-neovim/config/lua/mappings.lua | |
| parent | 86723a395d8ff81760529a4e804aca1ae6a63cfe (diff) | |
neovim: fixed incline and improved buffer management
Diffstat (limited to 'pkgs/custom-neovim/config/lua/mappings.lua')
| -rw-r--r-- | pkgs/custom-neovim/config/lua/mappings.lua | 10 |
1 files changed, 10 insertions, 0 deletions
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", "<leader>b", "Manage buffers", "") mapkey("n", "<leader>bb", "Go to next buffer", ":bn<cr>") mapkey("n", "<leader>bB", "Go to previous buffer", ":bp<cr>") mapkey("n", "<leader>bd", "Delete current buffer", ":bd<cr>") +mapkey("n", "<leader>bd", "Force delete current buffer", ":bd!<cr>") mapkey("n", "<leader>bp", "Open buffer picker", ":lua Snacks.picker.buffers()<cr>") mapkey("n", "<leader>bg", "Open buffer live grep picker", ":lua Snacks.picker.grep_buffers()<cr>") +mapkey("n", "<leader>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", "<leader>w", "Manage windows", "<C-w>") |
