I'm starting to use Vim 8 and work on setting up my .vimrc. I installed vim-fugitive using vim-plug. I can use the commands provided by the plugin. My problem is that I want to define custom commands to serve as git aliases. I followed this issue: https://github.com/tpope/vim-fugitive/issues/72 but when I try to use the command added by my autocmd call I get an error: not an editor command. I understood that it could be a timing problem between the plugin load and the command declaration but I wrote my autocmd after the plugin load by vim-plug. Here is an extract of my .vimrc:
" Installing/loading plugins
call plug#begin('~/.vim/plugged')
[...]
Plug 'tpope/vim-fugitive'
call plug#end()
" #########################################################
" #
" # Fugitive
" #
" #########################################################
augroup gitAlias
" Remove all gitAlias command
" Needed because they are added every time otherwise
autocmd!
autocmd User fugitive command! -nargs=0 Gpr :G pull --rebase
augroup END
If I run :command! -nargs=0 Gpr :G pull --rebase while in Vim, the custom command works. Perhaps the problem comes from the autocmd event but I can't find a way to make sure the event exists.