tpope / vim-obsession

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

Question: Your opinion about vim-prosession #15

Open dhruvasagar opened 10 years ago

dhruvasagar commented 10 years ago

Hey Tim,

Yesterday I wrote vim-prosession which leverages vim-obsession to allow for autoloading of sessions on launch (in case no arguments were passed to vim) as well as provides a simple command with completion to enable switching between sessions easily. The idea is to use a session per project and you can easily switch sessions when you wish to switch context. This enables cleaner & isolated project sessions that keep buffers & settings that belong only for that project / session.

Wanted to know what your thoughts on the same might be ?

tpope commented 10 years ago

So I've been using that VimEnter autocommand for a while with good results, although it still occasionally catches me by surprise. Maybe it's time to merge it in but disabled by default?

I certainly see a lot of value in a canonical central source of session files. I'm a biased against having a directory in .vim because I like to keep that for shared config only. (BTW, those directories are usually singular, so you might consider naming the default ~/.vim/session instead.) In sensible.vim I tried to find a canonical place to put that sort of stuff and failed miserably.

Lately my technique for switching being projects has been to make use of $CDPATH (and the Vim equivalent 'cdpath'). This plus globpath(&cdpath, '*/Session.vim') is giving me some cool ideas.

dhruvasagar commented 10 years ago

Yea I like the general idea, and am quite pleased with the results & the workflow. I am sure it can be improved in several ways.

I'd like this to be merged in too, I am perfectly fine having it disabled by default, though I am not quite sure how to approach the merging in. Need your help for that, if you could quickly review the code it would be great, it's pretty small so shouldn't take a lot of time.

I am not very sure I understand the concept of 'cdpath' or how it's used.

dhruvasagar commented 10 years ago

Also although I keep these within .vim, they're on .gitignore so they don't trouble git. I like to keep them there for the lack of a better place. I'll change the default to ~/.vim/session makes sense :).

dhruvasagar commented 10 years ago

I've been using autojump for a while, never knew about $CDPATH, this is epic! I'll add support for this and send a PR soon.

blueyed commented 8 years ago

@dhruvasagar Any update on that &cdpath approach? I could imagine using it from/in prosession additionally to the central place for session files? (let's consider moving it to an issue in prosession)

dhruvasagar commented 8 years ago

I haven't added that support, the central location seems to work better and most people don't have cdpath configured.

alex-shamshurin commented 5 years ago

vim-prosession is extremely useful for me.

kazurus commented 4 years ago

@dhruvasagar thanks for your solution. I had been spending a lot of hours before found your plugin

tpope commented 4 years ago

I've had a few years to think.

dhruvasagar commented 4 years ago

I've had a few years to think.

  • The VimEnter autocommand fires if there are zero filename arguments, which means it breaks for usecases like vim +Gstatus or vim -S/dev/null. Unless someone finds a workaround that's as good as dead.

At the moment I rely on argc() and StdInReadPost to skip cases file arguments and stdin. Other scenarios, last I checked weren't reliably detected.

  • I would be okay with a g:obsession_home variable that specifies a default path for relative filenames. Users could still use ./path to target the current directory.

Sounds fair

  • Does switching between sessions effectively mean sourcing the session file? I could see sticking that somewhere like :Obsession < file. I don't like the mess it creates if you have modified buffers, but I am fine to leave it as caveat emptor.

Switching means sourcing the session file, but also removing the current session's buffers (after stopping it's session)