From 83fe03455e4bab192f1b522101c52a8e5d4a6027 Mon Sep 17 00:00:00 2001 From: siduck Date: Fri, 29 Apr 2022 22:33:18 +0530 Subject: [PATCH] fix (#989) Prevents auto-focus of nvimtree when there are multiple buffers opened and current buffer is closed --- lua/core/utils.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/core/utils.lua b/lua/core/utils.lua index da714cd..074f316 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -3,10 +3,11 @@ local M = {} local cmd = vim.cmd M.close_buffer = function(force) - if force or not vim.bo.buflisted or vim.bo.buftype == 'nofile' then + if force or not vim.bo.buflisted or vim.bo.buftype == "nofile" then cmd ":bd!" else - cmd "bd" + -- switch to previous buffer then close current buffer + vim.cmd(":bp | bd" .. vim.fn.bufnr()) end end