Shougo / neobundle.vim

Next generation Vim package manager
MIT License
2.29k stars 168 forks source link

Loading 'on_cmd' not always working with tpope/vim-fugitive #490

Closed arakashic closed 8 years ago

arakashic commented 8 years ago

I am trying to perform lazy loading for tpope/vim-fugitive. Loading by command is not always working. The plugin can be correctly loaded if there is no file opened in vim. The plugin cannot be loaded once a file is opened.

The mininal vimrc for reproducing this problem is

set nocompatible
set rtp+=~/.vim/bundle/neobundle.vim/

call neobundle#begin(expand('~/.vim/bundle/'))
NeoBundleFetch 'Shougo/neobundle.vim'

NeoBundle 'tpope/vim-fugitive', {'on_cmd' : 'Gstatus'}

call neobundle#end()
filetype plugin indent on
NeoBundleCheck

Case 1. In a git managed directory foo and run vim. Then Gstatus command can correctly trigger the loading of the plugin.

Case 2. In a git managed directory foo and using vim to edit a file, e.g. vim bar. Then Gstatus command cannot load the plugin. The error message is

Error detected while processing function neobundle#autoload#_command:
line   11:
E492: Not an editor command: Gstatus

Case 3. In a git managed directory foo and run vim. Then open a file bar. Gstatus command cannot load the plugin. Error message is the same as case 2.

I am using the latest neobundle and fugitive. Both vim 7.4.622 and neovim 0.1.1 have this problem.

As far as I know, it only happens with fugitive. I have tried other plugins, they all work fine.

Shougo commented 8 years ago

You must specify on_path attribute. Because, vim-fugitive checks the path to define the commands(Gstatus).

NeoBundle 'tpope/vim-fugitive', {'on_cmd' : 'Gstatus', 'on_path' : '.*'}
tony commented 8 years ago

@Shougo:

Didn't this use to be done as

NeoBundleLazy 'my/gitplugin', {
\ 'autoload' { 'commands': ['list','of','commands']}
\ }

Is the intention of on_cmd to lazy-load the plugin? Why isn't it used with NeoBundleLazy? Why isn't it kept in the autoload dict? Did the format change?

Shougo commented 8 years ago

The format is changed. Your example is old style(It works though).

on_cmd is same with commands.

NeoBundleLazy is not needed. Because, neobundle loads it as lazy automatically.