Vim-plug: vim-fugitive on: 'Gstatus' not working

Created on 25 Sep 2016  路  3Comments  路  Source: junegunn/vim-plug

TL;DR
This line is not working for me
Plug 'tpope/vim-fugitive', { 'on': ['Glog', 'Gstatus'] } " Git in vim

The only thing that does work:
Plug 'tpope/vim-fugitive'

Inital problem:
Plug 'tpope/vim-fugitive', { 'on': ['Glog', 'Gstatus'] } " Git in vim

This one's a little strange. When I boot vim, I type h fugitive and get

E149: Sorry, no help for fugitive

Then I run :Glog

Error detected while processing function <SNR>2_lod_cmd:                                                                                                                             
line    3:                                                                                                                                                                           
E492: Not an editor command: Glog 

But when I type h fugitive it successfully loads the help file. The plugin seems to be partially loading. Any idea what might be the problem?

Other things I tried with same behavior:
Plug 'tpope/vim-fugitive', { 'on': ['Gstatus'] } " Git in vim

and
Plug 'tpope/vim-fugitive', { 'on': 'Gstatus' } " Git in vim

:Gstatus does not work, same error


NVIM 0.1.5                                                                                                                                                                           
Build type: RelWithDebInfo                                                                                                                                                           
Compilation: /usr/local/Library/ENV/4.3/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DDISABLE_LOG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std
=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -DHAVE_CONFIG_H -I/tmp/neovim20160924-8399-1y3dbc/neovim-0.1.5/build/config -I/tmp/ne
ovim20160924-8399-1y3dbc/neovim-0.1.5/src -I/tmp/neovim20160924-8399-1y3dbc/neovim-0.1.5/deps-build/usr/include -I/tmp/neovim20160924-8399-1y3dbc/neovim-0.1.5/deps-build/usr/include
 -I/tmp/neovim20160924-8399-1y3dbc/neovim-0.1.5/deps-build/usr/include -I/tmp/neovim20160924-8399-1y3dbc/neovim-0.1.5/deps-build/usr/include -I/tmp/neovim20160924-8399-1y3dbc/neovim
-0.1.5/deps-build/usr/include -I/tmp/neovim20160924-8399-1y3dbc/neovim-0.1.5/deps-build/usr/include -I/usr/local/opt/gettext/include -I/usr/include -I/Applications/Xcode.app/Content
s/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include -I/tmp/neovim20160924-8399-1y3dbc/neovim-0.1.5/build/src/nvim/auto -I/tmp/neovim20160924-8399-1y3dbc
/neovim-0.1.5/build/include                                                                                                                                                          
Compiled by [email protected]                                                                                                                                         

Optional features included (+) or not (-): +acl   +iconv    +jemalloc +tui                                                                                                           
For differences from Vim, see :help vim-differences                                                                                                                                  

   system vimrc file: "$VIM/sysinit.vim"                                                                                                                                             
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.1.5/share/nvim" 

  • Type:

    • [x] Bug

    • [ ] Enhancement

    • [ ] Feature Request

    • [ ] Question

  • OS:

    • [ ] All/Other

    • [ ] Linux

    • [x] OS X

    • [ ] Windows

  • Vim:

    • [ ] Terminal Vim

    • [ ] GVim

    • [x] Neovim

question

Most helpful comment

The following work to lazily load fugitive in case b:git_dir is defined:

    Plug 'tpope/vim-fugitive', {'on': []}
    function! s:vimplug_load_fugitive()
        if exists('b:git_dir')
            call plug#load('vim-fugitive')
            autocmd! vimplug_load_fugitive
            call fugitive#detect(expand('%:p'))
        endif
    endfunction
    augroup vimplug_load_fugitive
        au!
        au BufWinEnter * call s:vimplug_load_fugitive()
    augroup END

This does not help much, but I use it since I am using fugitive also in my statusline etc.

A similar approach could work for commands: define the command yourself, and call fugitive's detect method then.

Maybe that is something for vim-plug itself: allow to specify a callback to invoked for the 'on' handlers?!

All 3 comments

Hi, on-demand loading is basically a hack and it doesn't work with some plugins. Unfortunately fugitive falls in that category and there's not much vim-plug can do about it.

See https://github.com/junegunn/vim-plug/issues/164#issuecomment-73621232

The following work to lazily load fugitive in case b:git_dir is defined:

    Plug 'tpope/vim-fugitive', {'on': []}
    function! s:vimplug_load_fugitive()
        if exists('b:git_dir')
            call plug#load('vim-fugitive')
            autocmd! vimplug_load_fugitive
            call fugitive#detect(expand('%:p'))
        endif
    endfunction
    augroup vimplug_load_fugitive
        au!
        au BufWinEnter * call s:vimplug_load_fugitive()
    augroup END

This does not help much, but I use it since I am using fugitive also in my statusline etc.

A similar approach could work for commands: define the command yourself, and call fugitive's detect method then.

Maybe that is something for vim-plug itself: allow to specify a callback to invoked for the 'on' handlers?!

Was this page helpful?
0 / 5 - 0 ratings