tpope / vim-obsession

obsession.vim: continuously updated session files
http://www.vim.org/scripts/script.php?script_id=4472
1.76k stars 70 forks source link

Recovery for unnamed buffers using swap #66

Closed chrysn closed 3 years ago

chrysn commented 3 years ago

The most annoying fall-out of crashes I see is when I start writing something of which I don't yet know where it'd go, (well typically it sits around in this state for some time, contributing to the likelihood of it catching the next "system taken down by the USB stack" event).

As I understand Obsession it treats those like :mks would do -- the swap file is still around, but on restoring a new unnamed buffer is created, and without explicit action like vim -r ~/.local/share/nvim/swap/%home%chrysn.swX it doesn't catch on to the swap file.

Is persisting the right swap file for a buffer (as opposed to just going by path which usually works but not with unnamed buffers) something that obsession could do, or should this rather be addressed by upstream session creation?

tpope commented 3 years ago

I don't think Vim even exposes the name of the current buffer's swap file anywhere so this is probably difficult to impossible. At the risk of stating the obvious I recommend naming your buffers as soon as you create them. You can always :saveas if you change your mind.

tpope commented 3 years ago

Oh, Vim does have swapname() now, but I still suspect this would be difficult.