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

Native Obsession Status? #19

Closed sodapopcan closed 9 years ago

sodapopcan commented 9 years ago

I find it quite convenient to have Obsession's status showing.

To add the status to my statusline, I use the following function:

function! ObsessionStatus()
  let session = filereadable(v:this_session)
  if exists('g:this_obsession') && session
    return 'tracking'
  elseif session
    return 'paused'
  else
    return ''
  endif
endfunction

And then use the following two maps:

nnoremap go :Obsession<CR>:redraw!<CR>
nnoremap gO :Obsession!<CR>:redraw!<CR>

I'm not too crazy about these maps. I would much rather just hook into Obsession so I can continue to use :O<CR> and :O!<CR>.

I'm also not sure that the redraw!s are the correct solution to getting the status to update. It feels messy but was all I could come up with.

Would you be open to including this in the plugin itself? Obviously the Status function would need to change what it returns. I'm also not 100% sure the logic is sound... I don't handle the exceptional case where g:this_obsession and b:this_session is not set. In any event, I'm looking for a fugitive#status() analogue here.

Thanks!

tpope commented 9 years ago

If you are trying to force a status line redraw, you can do :let &readonly = &readonly. I'd accept a pull request to add that to the :Obsession implementation.