tpope/vim-obsession

Sourcing Session.vim does not appear to continue session tracking

amadeus opened this issue · 8 comments

I've noticed recently that when I source a Session file, the session tracking no longer seems to work. The only workaround right now is for me to pause/resume (:Obesession, and then another :Obesession) and then everything continues as before.

tpope commented

Check for let g:this_obsession = ... in the session file.

let g:this_obsession = v:this_session
let g:this_obsession_status = 2

Actually, here's an entire Session file, in case that helps:

let SessionLoad = 1
if &cp | set nocp | endif
let s:so_save = &so | let s:siso_save = &siso | set so=0 siso=0
let v:this_session=expand("<sfile>:p")
silent only
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
  let s:wipebuf = bufnr('%')
endif
set shortmess=aoO
badd +1 ~/Development/discord/discord_app/Dispatcher.js
badd +0 ~/Development/discord/discord_app/styles/auth.styl
badd +0 ~/Development/discord/discord_app/Constants.js
argglobal
silent! argdel *
edit ~/Development/discord/discord_app/styles/auth.styl
set splitbelow splitright
wincmd _ | wincmd |
vsplit
1wincmd h
wincmd w
wincmd t
set winheight=1 winwidth=1
wincmd =
argglobal
let s:l = 1 - ((0 * winheight(0) + 33) / 67)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
1
normal! 0
wincmd w
argglobal
edit ~/Development/discord/discord_app/Constants.js
let s:l = 1 - ((0 * winheight(0) + 33) / 67)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
1
normal! 0
wincmd w
2wincmd w
wincmd =
tabnext 1
if exists('s:wipebuf')
  silent exe 'bwipe ' . s:wipebuf
endif
unlet! s:wipebuf
set winheight=1 winwidth=20 shortmess=ITaoc
let s:sx = expand("<sfile>:p:r")."x.vim"
if file_readable(s:sx)
  exe "source " . fnameescape(s:sx)
endif
let &so = s:so_save | let &siso = s:siso_save
let g:this_session = v:this_session
let g:this_obsession = v:this_session
let g:this_obsession_status = 2
doautoall SessionLoadPost
unlet SessionLoad
" vim: set ft=vim :

Any thoughts on this, Sir Pope? 😬

tpope commented

Looks correct. I'm not really sure what's going on. :(

I can work around it by doing:

augroup obsessionfix
  autocmd!
  autocmd SessionLoadPost * silent :Obsession|silent :Obsession
augroup END

But yeah, something is very strange. I even disabled every other plugin except Obsession, and the problem still persists.

Is there some specialized hook that's supposed to fire to the Obsession plugin to persist the session?

tpope commented

All it does is call s:persist() on BufEnter and VimLeavePre, which runs if g:this_obsession is set and g:SessionLoad is not. There's really not much that can silently go wrong.

Lol I am an idiot on this. Dug into it again - and realized that I had configured my plugin manager to not source this plugin until :Obsession is executed... so of course it could never resume... lol