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 ] Project Sessions #60

Open
Chaitanyabsprip opened this issue Aug 26, 2021 · 11 comments · Fixed by #63
Open

[ Feature Request ] Project Sessions #60

Chaitanyabsprip opened this issue Aug 26, 2021 · 11 comments · Fixed by #63
Labels
enhancement New feature or request

Comments

@Chaitanyabsprip
Copy link
Contributor

Chaitanyabsprip commented Aug 26, 2021

I was inspired by this plugin and had an idea of plugin that manages project sessions. I am usually working with multiple windows, production code on one side and tests on other or just multiple windows from different files belonging to a feature. I find the process of reopening and rearranging these windows and buffers dreadful and am often too lazy to do it. It would be a nice idea if as an extension to auto-session I could have a command that stores the current layout and open buffers as a session in a project level hidden directory, something like what .idea does for intelliJ based IDEs and .vscode does for well, VS Code. Let me know if this is a feature this plugin's ideology warrants it to have.

EDIT: This feature will be a great addition in support of session-lens. Being able to traverse through different sessions for a project. Effectively these will be mini work-spaces.

@Chaitanyabsprip Chaitanyabsprip changed the title Project Sessions [ Feature Request ] Project Sessions Aug 26, 2021
@rmagatti
Copy link
Owner

rmagatti commented Aug 29, 2021

Hey @Chaitanyabsprip thanks for the submission!

The one drawback I can see from something like this is having to manage your multiple sessions per project in a more manual way. The thing I love about auto-session is the fact that I don't have to think about it 99% of the time.

I can't really work it out in my head right now how the flow around these sub-sessions would be initially, but I'll admit I'm intrigued. Let's keep the discussion going here!

@Chaitanyabsprip
Copy link
Contributor Author

How I have thought it out is that there will be global sessions for directories that would be stored in auto_session_root_dir and there will be project level local sessions that will be stored in, say .session directory in the root of the project. The global sessions will work as they already do, everything relating to project level sessions will be handled manually. The functionality of session-lens plugin can be extended to list the local sessions. the prompt for setting the name of the local session, if left empty, would need a default name be set for the session.

@Chaitanyabsprip
Copy link
Contributor Author

The fact that the global sessions will continue to work as they are would ensure that you dont have to think at all about automatically loading the session that you left neovim on. Just on top of that the use will have the option to quickly set up a layout(with respective files) from the saved sessions in .session directory. Having this option, the use is saving time from opening multiple files and setting it up manually, this will just save all those mini-workspaces for the user and having session-lens would allow them to switch between these seamlessly. This is a lot quicker that using tree explorer or even any kind of fuzzy file explorers to find files and set them up manually.

@wilriker
Copy link
Contributor

Ignore the above linking of the PR, had the wrong issue number in my commit message, sorry.

@davidvalaz
Copy link

I just want to weigh in on this and say this would be really exciting.

I use dhruvasagar/vim-prosession currently as my workflow means working across multiple git branches for my project and it has lovely support for it.

@rmagatti rmagatti added the enhancement New feature or request label Aug 31, 2021
@rmagatti rmagatti reopened this Aug 31, 2021
@rmagatti
Copy link
Owner

I use dhruvasagar/vim-prosession currently as my workflow means working across multiple git branches for my project and it has lovely support for it.

@davidvalaz Could you describe your workflow perhaps in a bit more detail? I'd like to understand the needs people have a bit more before I start working on something.

@davidvalaz
Copy link

Absolutely.

So I am generally only really working across a couple of projects at a time. However across those projects I will be diving across various branches and pull requests to review changes and write/amend code. As such I'll have a few splits with many buffers open.

From my terminal I may choose to switch a branch, open up Neovim, use Prosession . and restore my Neovim session complete with splits, buffers et al. This allows me to quickly get back into my workflow. I then may choose to checkout a new feature a developer is working on so I'll switch to feature/new-cool-feature and hit Prosession . to start a new session and then begin my review.

I also use a cool little helper (which is exposed by tpope/vim-obsession) to display that a session is active in my statusline (the cloud with the tick):

Screen Shot 2021-08-31 at 11 27 53@2x

Sometimes I forget to use Prosession . so this is just a minor visual reminder for me.

In summary, being able to automatically start a session across a git branch is what I'm looking for in a session plugin.

@rmagatti
Copy link
Owner

I wonder where Prosession stores it's sessions. This could technically be achieved relatively easily if you have session files in the project's root with a name matching the branch for example. Ofc in that case some plugin code would have to change to support the loading of those sessions, or really just some sort of precedence logic for what to load first.

I do wonder if there's a better way to go about it, I'm not a fan of having session files in the project directories themselves.
Maybe some sort of indicator of sub-sessions but still stored in the default sessions dir auto-session already uses would be a better approach. 🤔

@davidvalaz
Copy link

davidvalaz commented Aug 31, 2021

I do wonder if there's a better way to go about it, I'm not a fan of having session files in the project directories themselves.
Maybe some sort of indicator of sub-sessions but still stored in the default sessions dir auto-session already uses would be a better approach. 🤔

Completely agree! Prosession does allow you to customise the directory where sessions are stored. I use the following:

vim.g.prosession_dir = vim.fn.stdpath('config')..'/.session' 

I'm assuming it tries to load from that directory only when you run Prosession .

I back up my config folder with Tresorit (like Dropbox but way more secure) and also in my dotfiles repo, so it's nice to keep my sessions files close to my Neovim config 😄 .

@Chaitanyabsprip
Copy link
Contributor Author

I wonder where Prosession stores it's sessions. This could technically be achieved relatively easily if you have session files in the project's root with a name matching the branch for example. Ofc in that case some plugin code would have to change to support the loading of those sessions, or really just some sort of precedence logic for what to load first.

I do wonder if there's a better way to go about it, I'm not a fan of having session files in the project directories themselves. Maybe some sort of indicator of sub-sessions but still stored in the default sessions dir auto-session already uses would be a better approach. 🤔

Instead of directly having files in the global sessions directory, create directories for each session, anyway a session belongs to a directory so this won't distrupt any current behaviour, but this will allow for you to save the sub-sessions in that directory indicating the parent project/directory and the name of the file indicating git branch/custom name. I am eagerly waiting for this feature. If you've started working on this let me know which branch it is, maybe I could contribute whenever I get time.

@rmagatti
Copy link
Owner

rmagatti commented Nov 3, 2021

Hey @Chaitanyabsprip, I have not started any work on this yet.
Your suggestion seems like it could work well. I have just really not had the time lately to dive into making this happen.

One thing to note with your approach is session-lens might need to change how it works in order to be able to fuzzy find through the sub-sessions. Not a big deal, but something of note.

I'd be more than happy to review a PR and generally help out if you or anyone else is able to dedicate to this before I end up getting to it myself.

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

Successfully merging a pull request may close this issue.

4 participants