You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When deleting a file that is open, the corresponding buffer is still loaded and you get a "no longer available" message.
It would be nice to have an option that would automatically delete buffers that correspond to deleted files, and save+reopen buffers for the moved files.
Provide background
Moving/deleting open files is annoying atm.
Additional details
Got the idea from tpope/vim-eunuchs :Remove
The text was updated successfully, but these errors were encountered:
Yeah, this would be possible. The current behavior intentionally leaves the buffers in-place as sort of an extra protection from data loss, but we could potentially add another config option to remove those buffers. Will add to my backlog
Astrocommunity gets this done here. My lua-fu is too weak so my struggles to piece together something distro-agnostic are real Maybe someone can improve on this?
vim.api.nvim_create_autocmd("User", {
desc = "Close buffers when files are deleted in Oil",
pattern = "OilActionsPost",
callback = function(args)
if args.data.err then return end
for _, action in ipairs(args.data.actions) do
if action.type == "delete" then
local _, path = require("oil.util").parse_url(action.url)
local bufnr = vim.fn.bufnr(path)
if bufnr ~= -1 then vim.cmd.bwipeout { bufnr, bang = true } end
end
end
end,
})
This is sorta working but I am always left with an orphaned buffer with foo.txt loaded.
echo foo > {foo,bar}.txt
vi {foo,bar}.txt
With the 2 buffers now open, I now:
Run Oil
dd foo.txt and bar.txt
:w and confirm
The bar.txt buffer is removed but the other is still showing despite foo.txt being deleted from the directory.
Did you check existing requests?
Describe the feature
When deleting a file that is open, the corresponding buffer is still loaded and you get a "no longer available" message.
It would be nice to have an option that would automatically delete buffers that correspond to deleted files, and save+reopen buffers for the moved files.
Provide background
Moving/deleting open files is annoying atm.
Additional details
Got the idea from
tpope/vim-eunuch
s:Remove
The text was updated successfully, but these errors were encountered: