Using NeoVim I am having problems with the :Gpush
command locking up the editor. Does anyone have a work around for this problem?

- 550
- 4
- 14
2 Answers
I understand that your problem is that you need to manually type username/password from your shell when you're pushing to github. I don't think that GPush was designed to allow for that. this probably solves your problem
:te git push
you'll likely see a terminal window on your screen asking for username/password. You'll need to type i
to enter insert mode on your terminal and should be good to go.

- 1,081
- 6
- 14
-
Worked great for me. Is there any way to automatically put the cursor in the location to enter the username? – Cogwizzle Feb 20 '18 at 14:36
-
I guess that `autocmd TermOpen * startinsert` should do the job – sudavid4 Feb 20 '18 at 18:09
fugitive's push will work synchronously on nvim. from the fugitive help file
*fugitive-:Gpush*
:Gpush [args] Invoke git-push, load the results into the |quickfix|
list, and invoke |:cwindow| to reveal any errors.
|:Dispatch| is used if available for asynchronous
invocation.
the thing is that there isn't a dispatch function on nvim. You could run
!git push &
but this will prevent you from seeing the output of the command(which is bad cuz: what if the fit push failed?)
Here is a replacement function for fugitive's GPush that solved for me, might be useful for you too(put it in your init.vim). It harnesses nvim's async job-control :h job-control
and shows you the output in the preview window :h preview-window
function! s:shell_cmd_completed(...) dict
wincmd P
setlocal modifiable
call append(line('$'), self.shell)
call append(line('$'), '########################FINISHED########################')
call append(line('$'), self.pid)
call jobstop(self.pid)
normal! G
setlocal nomodifiable
wincmd p
endfunction
function! s:JobHandler(job_id, data, event) dict
let str = join(a:data)
wincmd P
call append(line('$'), str)
normal! G
wincmd p
endfunction
function! GitPush()
let s:shell_tmp_output = tempname()
execute 'pedit '.s:shell_tmp_output
wincmd P
wincmd J
setlocal modifiable
setlocal nobuflisted
nnoremap <buffer>q :bd<cr>
wincmd p
let s:callbacks = {
\ 'on_stdout': function('s:JobHandler'),
\ 'on_stderr': function('s:JobHandler'),
\ 'on_exit': function('s:shell_cmd_completed'),
\ 'shell': 'git push'
\ }
let pid = jobstart('git push', s:callbacks)
let s:callbacks.pid = pid
endfunction
command! GitPush call GitPush()

- 1,081
- 6
- 14
-
Thanks for the response. I attempted to put this into my init.vim file. I made a push to a repository and running the :GitPush command also locked up my nvim terminal. Could it be something to do with the terminal I am using? – Cogwizzle Feb 12 '18 at 12:49
-
what terminal are you using? this is very strange indeed. What happens if you just run `:call jobstart('git push')`? does this also lock your terminal? – sudavid4 Feb 12 '18 at 15:08
-
Yes that command locks up my terminal as well. I use the default Ubuntu terminal. – Cogwizzle Feb 12 '18 at 15:19
-
what version of neovim are you using? What about `!git push` or `!git push &`? Are you able to push from your terminal outside of vim? – sudavid4 Feb 12 '18 at 15:31
-
Yes I am able to push from outside of nvim. My current version is v0.2.2. – Cogwizzle Feb 12 '18 at 15:34
-
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/164985/discussion-between-sudavid4-and-joseph-fehrman). – sudavid4 Feb 12 '18 at 16:30