From bb52f8676ea3ac8082e4c0af17345bf1304e82c1 Mon Sep 17 00:00:00 2001 From: Mikolaj_Bien Date: Thu, 15 May 2025 08:21:17 +0200 Subject: [PATCH] feat: add buffer delete --- init.lua | 8 ++++++++ lua/config/keymap.lua | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/init.lua b/init.lua index 24deaea7..819cdad9 100644 --- a/init.lua +++ b/init.lua @@ -86,6 +86,14 @@ vim.api.nvim_create_autocmd('TextYankPost', { vim.highlight.on_yank() end, }) + +vim.api.nvim_create_autocmd('FileType', { + pattern = 'neo-tree', + callback = function() + vim.wo.winfixwidth = true + end, +}) + require 'config.keymap' require 'config.lazy' diff --git a/lua/config/keymap.lua b/lua/config/keymap.lua index 38a22b50..0eb5c922 100644 --- a/lua/config/keymap.lua +++ b/lua/config/keymap.lua @@ -58,3 +58,18 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the upper win -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` + +-- buffers + +local function close_other_buffers() + local current = vim.api.nvim_get_current_buf() + local bufs = vim.api.nvim_list_bufs() + + for _, buf in ipairs(bufs) do + if vim.api.nvim_buf_is_loaded(buf) and buf ~= current then + vim.api.nvim_buf_delete(buf, { force = true }) + end + end +end +vim.keymap.set('n', 'bd', ':bd', { desc = 'Close current buffer' }) +vim.keymap.set('n', 'bo', close_other_buffers, { desc = 'Close all buffers except current' })