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

[Feature Request] Seperate AutoSave and AutoCreate #59

Closed
wilriker opened this issue Aug 24, 2021 · 8 comments
Closed

[Feature Request] Seperate AutoSave and AutoCreate #59

wilriker opened this issue Aug 24, 2021 · 8 comments

Comments

@wilriker
Copy link
Contributor

I would like to see the possibility to separate auto-saving of sessions from auto-creation of sessions. What I mean is that an existing session (created e.g. manually with :SaveSession) will be saved on VimLeave as of now but it will not create a new session if there is none already.

Currently one can only specify auto_session_suppress_dirs but that is of course unfeasable if one only wants to create and track a few explicit sessions.

Alternatively (but of course less flexible) would be to provide auto_session_include_dirs as an inverse to auto_session_suppress_dirs.

@rmagatti
Copy link
Owner

Hey, thanks for the subimssion!

There's an ongoing PR for adding an include_dirs feature. #58

Now as for the feature request itself:

What I mean is that an existing session (created e.g. manually with :SaveSession) will be saved on VimLeave as of now but it will not create a new session if there is none already.

I'm not sure I follow what you mean, running a :SaveSession manually effectively creates a session by running a mksession, so "create" and "save" at the same time.
The command won't actually enable auto-saving through VimLeave as it's a manual action in this case.

Maybe I'm misunderstanding what you'd like to get from the proposed feature, would you mind sharing some more about your config and the behaviour you're expecting overall?

@wilriker
Copy link
Contributor Author

I was afraid that I would not be able to convey what I mean first try. :-D

So here, is what I currently have:

  • I have a total of 8 sessions as of right this moment
  • I also have my home directory excluded via auto_session_suppress_dirs

Now to what I would like to see:

  • Whenever I open one of these 8 sessions it should be saved when I either close neovim or load another session (via session-lens - great plugin by the way, using it constantly throughout my working day)
  • There should never be any session automatically created in any other directory unless I manually call :SaveSession

In other words, I'd like auto-session to continue updating existing sessions but it should never create a session for a directory by itself similar to

  1. When starting nvim . with some argument, auto-session will do nothing.

just that I want this to be the default. So one simple rules (I guess)
Is there already a session for the current cwd?

  • Yes: update it
  • No: do not create one

Reason for this request (maybe that explains it better): I do use a rooter plugin to change cwd to the root of a file opened. When I now navigate into source-code of a library in e.g. a Golang project this plugin will change cwd to the root of this library as represented on my disk. That will cause auto-session to say "oh wait, there is no session here, so I am going to create one" and I now have an unwanted extra session in a compiler-managed dependency directory.

@rmagatti
Copy link
Owner

Ah I see, I think this PR that was just merged will help with that.
#58

I'll give this some more thought as well to see if there's anything else that could be done 😄

@wilriker
Copy link
Contributor Author

The merged PR will solve my problem although in a less flexible way. If I ever want to add a new session I will have to change auto-session configuration. In the solution I proposed it would have been sufficient to just call :SaveSession instead.

I'll see if I can come up with a PR next week unless you are quicker. ;-)

@rmagatti
Copy link
Owner

rmagatti commented Aug 29, 2021

Right I do see your point there. It'd be nice to have a way to break these down as long as the current behaviour is still the default one.

Yeah if you can get to it before I can that'd be lovely, thanks for the help 😊

@idr4n
Copy link

idr4n commented Mar 24, 2022

Thanks @rmagatti for this very nive plugin. This is exactly the behavior that I wanted to setup but it took me some time to realize that the option auto_session_create_enabled existed as it is not documented yet.

@rmagatti
Copy link
Owner

@ivanddm, oh I hadn't realized this was undocumented, thanks for pointing it out! I'd greatly appreciate it if you could send me a PR for an updated readme! 😊

@idr4n
Copy link

idr4n commented Mar 24, 2022

Sure, will do so ASAP @rmagatti.

Thanks again!

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