vim-gina icon indicating copy to clipboard operation
vim-gina copied to clipboard

Have :gina branch open to master

Open srcrip opened this issue 7 years ago • 4 comments

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.

srcrip avatar Aug 21 '18 17:08 srcrip

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

e.g.

:Gina +/master branch

lambdalisue avatar Aug 27 '18 08:08 lambdalisue

Maybe :Gina branch +/master

lambdalisue avatar Aug 27 '18 08:08 lambdalisue

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')
      \)

lambdalisue avatar Sep 14 '18 19:09 lambdalisue

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

srcrip avatar Sep 26 '18 17:09 srcrip