-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add an opt-in feature that saves a session per git branch (if you are in a git repo). #121
Conversation
bare-bones effort to get session per git branch. |
-- get the current git branch name, if any, and only if configured to do so | ||
local function get_branch_name() | ||
if AutoSession.conf.auto_session_use_git_branch then | ||
local out = vim.fn.systemlist('git rev-parse --abbrev-ref HEAD') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a drive by comment but this function systemlist
is synchronous and will block nvim till it completes so if this is run at startup it will slow users startups down. An alternative is to use jobstart
and pass a callback to receive the result, but then the whole outer function will have to adapt to use callbacks as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm aware. Redoing / adapting auto-session to use jobs isn't going to happen. At least not by me. Sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WhoIsSethDaniel no worries, fully a drive by comment, just pointing it out in case you weren't aware
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good input, this is something I've thought about a bit, I'm just not sure if the core restoring and saving a session behaviour could actually be offloaded to a job. 🤔 As far as this git functionality, it's a good use-case for a job I'd say.
I also agree @WhoIsSethDaniel that job support is a feature better suited for the rewrite. I'll keep this in mind when working on it.
Thanks for chiming in @akinsho !
I'll try to test this out sometime this weekend, will merge if it looks good then! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a while to get to this but this works well 👍
@WhoIsSethDaniel I'll try and add some documentation about this feature in the readme before merging, or you can do it if you happen to have a free minute. Either way, nice work, thanks for the contribution! 🎉 |
I may have time tonight. Thanks for the review. |
I added the new config element to README.md |
No description provided.