Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Have :gina branch open to master #177

Open
srcrip opened this issue Aug 21, 2018 · 4 comments
Open

Have :gina branch open to master #177

srcrip opened this issue Aug 21, 2018 · 4 comments
Labels

Comments

@srcrip
Copy link

srcrip commented Aug 21, 2018

I often use this plugin to view my branches on a very large repo, and it'd be really nice if there was an option to have it default to having the cursor vertically centered on master when the view opens up. This way you could quickly make new branches off of master.

Yeah I know you can make a branch of master quickly with the vim command line but I much prefer the visual workflow that gina provides to branches in git.

@lambdalisue
Copy link
Owner

Not sure but does https://vim-jp.org/vimdoc-en/editing.html#+cmd helps you?

e.g.

:Gina +/master branch

@lambdalisue
Copy link
Owner

Maybe :Gina branch +/master

@lambdalisue
Copy link
Owner

I found that above tech does not work.

While gina read buffer content asynchronously, +/master is not available because there is no content just after :Gina branch.

You can use gina#core#emitter#subscribe() to subscribe command:called event like

function! s:on_branch(name, ...) abort
  if a:name !=# 'branch'
    return
  endif
  let params = gina#core#buffer#parse(expand('%'))
  if empty(params) || params.scheme !=# 'branch'
    return
  endif
  " Find 'master' and move.
  /master
endfunction

call gina#core#emitter#subscribe(
      \ 'command:called',
      \ funcref('s:on_branch')
      \)
@srcrip
Copy link
Author

srcrip commented Sep 26, 2018

Thanks @lambdalisue. That function works great. I think other people would really appreciate this, maybe this could work its way into master somehow?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
2 participants