From 071081f58285e868ecbe7cbfcc610d0f60c14247 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Wed, 6 Sep 2023 16:06:43 -0500 Subject: [PATCH] feat(nvim): add autocmd to remove no name buffers --- dots/.config/nvim/lua/core/autocmds.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dots/.config/nvim/lua/core/autocmds.lua b/dots/.config/nvim/lua/core/autocmds.lua index 7e8b59f9..0eac36e7 100644 --- a/dots/.config/nvim/lua/core/autocmds.lua +++ b/dots/.config/nvim/lua/core/autocmds.lua @@ -28,6 +28,17 @@ M.setup = function() end, }) + -- NOTE: Removes No Name buffers, thanks + -- https://www.reddit.com/r/neovim/comments/16b0n3a/comment/jzcbhxo/?utm_source=share&utm_medium=web2x&context=3 + vim.api.nvim_create_autocmd("BufHidden", { + group = augroup, + desc = "Delete [No Name] buffers", + callback = function(event) + if event.file == "" and vim.bo[event.buf].buftype == "" and not vim.bo[event.buf].modified then + vim.schedule(function() pcall(vim.api.nvim_buf_delete, event.buf, {}) end) + end + end, + }) -- NOTE: Launches a different program for a given filetype instead of opening it in Neovim local intercept_file_open = true vim.api.nvim_create_user_command("InterceptToggle", function()