tpope/vim-obsession

Stopping the Obsession

Jasha10 opened this issue · 1 comments

Hi,

What's the recommended way to guarantee that Session.vim is gone and the plugin has stopped?

I've tried :Obsession!. The docs say:

:Obsession!             Stop obsession and delete the underlying session file.

and this would seem to be what I'm asking for. And if a Session.vim file exists, it is what I'm asking for.
But if a Session.vim file does not exist, then invoking Obsession! creates a new Session.vim file and starts tracking state, giving the opposite result.

My use case is: I want to map the letter Q to delete Session.vim (if it exists) and then exit vim.
I am planning another map (<Leader>E) to ensure Obsession is running before exiting.

Thanks in advance.

tpope commented

This is the conditional that decides whether to delete:

let session = get(g:, 'this_obsession', v:this_session)
try
if a:bang && empty(a:file) && filereadable(session)

So to always delete, your map will need to invert that third clause:

nmap <script> Q :<C-U>if filereadable(get(g:, 'this_obsession', v:this_session))|Obsession!|endif|qa<CR>