Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal command to load session. #12

Open
timsofteng opened this issue Sep 8, 2022 · 3 comments
Open

Terminal command to load session. #12

timsofteng opened this issue Sep 8, 2022 · 3 comments

Comments

@timsofteng
Copy link

Hello. I used to use obsession for my sessions management. But it is slightly slow...
May I use possession the same way as obsession?
I normally do :Obsession in session which I want to track and than i do nvim -S if I want restore session for current dir and just nvim if I doesn't.
How can I do it with possession?

@jedrzejboczar
Copy link
Owner

Hi, one thing that vim-obsession does differently (as far as I understand) is that it saves session files in the current directory. possesion uses a common directory for all sessions (e.g. ~/.local/share/nvim/possession/) and the current code would require quite a bit of refactoring if the common directory approach is a no-go for you.

But if you would be ok with common directory, than the potential workflow could be:

  • in setup {...} set autosave.current = true
  • use PossessionSave yoursessionname to save the session; it will now also be auto-saved before quitting nvim due to autosave.on_quit = true
  • when you want to start nvim using the session for current dir you would use a command like PossessionLoadCwd that would check existing sessions and find a best match based on cwd, then load it

To make this work we would need to implement the metioned PossessionLoadCwd command. Available sessions can be found using as_list() and then session.cwd can be checked. There are even some helper functions in query.lua that could be used, probably some combination like M.group_by(M.by_root_dir(current_dir), sessions) and then find best match (closest to cwd).

What do you thing of such a workflow vs what you are currently using?

@Justinfan827
Copy link

I have a use case for something like this. I'd like to be able to quickly quit nvim and re-enter right where i left off for when i make updates to my nvim config.

@jedrzejboczar
Copy link
Owner

@Justinfan827 Would saving temporary session work? You would work on something, then quit, this would save tmp session, then you can open nvim and use PossessionLoad tmp. I'm suggesting this soultuion, as I don't think I'll have time to work on CWD-based session in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants