possession.nvim
possession.nvim copied to clipboard
Automatic session save/restore
As noted in https://github.com/jedrzejboczar/possession.nvim/issues/2, it would be nice to have this kind of functionality built-in.
Currently one could use the provided API to do this in their config: list avaliable sessions and compare sessions[X].cwd to current working directory to select the session we want.
Adding this feature to the plugin would require some configuration options like:
- should be enabled by a config option (disabled by default)
- do we want to match CWD exactly, or if opening Vim in
/dir/a/bsession with cwd/dir/ashould be used? - or should we actually load the previously open session and not care about cwd whatsoever?
- when to auto-save the session?
- config option for enabling this could be a boolean or a user function that returns a boolean - this can offload some more logic to users
+1 for this functionality.
Regarding the cwd, I think matching exactly is the least surprising behavior.
If you decide to just open the previous session, make sure that cwd is set.
I agree with exact matching
or should we actually load the previously open session and not care about cwd whatsoever?
I think it would be nice to indeed check cwd
Even now, when doing PossessionLoad without passing a name, I would intuitively expect it to load the session according to cwd and not the last general session.
With https://github.com/jedrzejboczar/possession.nvim/pull/7 by @wasden already merged, automatic save functionality should work without issues. As for auto restore, I hope I will implement it somewhere soon.
Even now, when doing
PossessionLoadwithout passing a name, I would intuitively expect it to load the session according tocwdand not the last general session.
Yeah, I already noticed that the last general session is problematic, especially when opening two Neovim instances, because they will be overwriting the last session of each other. This is especially annoying for PossessionSave, so I think I will change the behavior (at the very least for save) when I find time to work on the restore function.
Any updates on this?
@aaditeynair Not really, I didn't have time to work on this and auto-restore is not something I would personally need. If anyone is willing to give it a try then I'd be happy to merge :)
I'll try to do when I get some free time.
Partially resolved, continued in https://github.com/jedrzejboczar/possession.nvim/issues/45#issuecomment-1817597856