首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NeoVim逃逸插件Gpush锁定

NeoVim逃逸插件Gpush锁定
EN

Stack Overflow用户
提问于 2018-02-09 23:38:07
回答 2查看 545关注 0票数 2

在使用NeoVim时,我遇到了:Gpush命令锁定编辑器的问题。有谁有解决这个问题的办法吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-02-18 14:53:47

我理解你的问题是,当你推送到github时,你需要从你的shell中手动输入用户名/密码。我不认为GPush在设计时就考虑到这一点。这可能解决了你的问题

代码语言:javascript
复制
:te git push

您可能会在屏幕上看到一个终端窗口,要求输入用户名/密码。您需要输入i才能在终端上进入插入模式,这样就可以了。

票数 1
EN

Stack Overflow用户

发布于 2018-02-12 17:30:22

逃犯的推送将在nvim上同步工作。从逃犯帮助文件中

代码语言:javascript
复制
                                                *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.

问题是nvim上没有分派函数。你可以跑

代码语言:javascript
复制
!git push &

但这将阻止您看到命令的输出(这是不好的,因为:如果fit推送失败了怎么办?)

这是一个为我解决的逃犯GPush的替换函数,可能对你也有用(把它放在你的init.vim中)。它利用nvim的异步作业控制:h job-control,并在预览窗口:h preview-window中显示输出

代码语言:javascript
复制
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()
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48709262

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档