feat(nvim): add autocmd to remove no name buffers

This commit is contained in:
Price Hiller 2023-09-06 16:06:43 -05:00
parent e01700dab6
commit 071081f582
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8

View File

@ -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()