From d556ce0aca97d470ab91c07230c5b7bff83c037c Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Mon, 15 Jul 2024 20:24:37 +0200 Subject: [PATCH] delete buffer keymap replaced by lua --- lua/keymaps.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 4078acb..1570330 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -45,7 +45,14 @@ vim.keymap.set('n', 'cdh', 'cd ' .. vim.g.base_dir .. '', { des vim.keymap.set('n', 'cdn', 'cd ' .. vim.fn.stdpath 'config' .. '', { desc = '[C]hange [D]irectory to [N]eovim' }) -- Delete current buffer without closing window -vim.keymap.set('n', 'bd', 'bpspbnbd', { desc = '[B]uffer [D]elete' }) +vim.keymap.set('n', 'bd', function() + -- Get current buffer + local buf = vim.api.nvim_get_current_buf() + -- Switch to different buffer + vim.cmd 'bp' + -- Delete saved buffer + vim.api.nvim_buf_delete(buf, {}) +end, { desc = '[B]uffer [D]elete' }) -- Switch to between buffers vim.keymap.set('n', 'bp', 'bp', { desc = '[B]uffer [P]revious' }) vim.keymap.set('n', 'bn', 'bn', { desc = '[B]uffer [N]ext' })