Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to setup "Ag" command via Autoload: E464: Ambiguous use of user-defined command #9

Closed
blueyed opened this issue Jun 7, 2014 · 2 comments · Fixed by #10
Closed

Comments

@blueyed
Copy link
Contributor

blueyed commented Jun 7, 2014

tplugin does not pick up the "Ag" command from the ag plugin: https://github.com/ervandew/ag

:command Ag
!   Ag          +          customlist call s:Autoload(1, ['…/vim/bundle', 'command -bang -nargs=+ -complete=customlist,<SNR>2_Complete Ag', 'ag', 'ag
'], "<bang>", [], <q-args>)
!   AgRelative  +          customlist call s:Autoload(1, ['…/vim/bundle', 'command -bang -nargs=+ -complete=customlist,<SNR>2_CompleteRelative AgRela
tive', 'ag', 'ag'], "<bang>", [], <q-args>)
    Agrep       *          file      call s:Autoload(1, ['…/vim/bundle', 'command! -nargs=* -complete=file Agrep', 'grep', 'grep'], "<bang>", [], <q-
args>)
    AgrepAdd    *          file      call s:Autoload(1, ['…/vim/bundle', 'command! -nargs=* -complete=file AgrepAdd', 'grep', 'grep'], "<bang>", [],
<q-args>)

:Ag foo
DBG s:Autoload ['ag', 'ag']
DBG LoadPlugins [1, '…/vim/bundle/ag', ['…/vim/bundle/ag/plugin/ag.vim']]
DBG LoadPlugins …/vim/bundle/ag/plugin/ag.vim
Exception Vim:E464: Ambiguous use of user-defined command: Ag foo from function <SNR>2_Autoload, line 21
E471: Argument required

:command Ag
    Name        Args Range Complete  Definition
!   AgRelative  +          customlist :call <SNR>76_Ag(<q-args>, 1, '<bang>')
    Agrep       *          file      call s:Autoload(1, ['…/vim/bundle', 'command! -nargs=* -complete=file Agrep', 'grep', 'grep'], "<bang>", [], <q-
args>)
    AgrepAdd    *          file      call s:Autoload(1, ['…/vim/bundle', 'command! -nargs=* -complete=file AgrepAdd', 'grep', 'grep'], "<bang>", [],
<q-args>)
@blueyed blueyed changed the title Does not define "Ag" command: E464: Ambiguous use of user-defined command Fails to setup "Ag" command via Autoload: E464: Ambiguous use of user-defined command Jun 7, 2014
@tomtom
Copy link
Owner

tomtom commented Jun 7, 2014

I guess the problem here is that the :Ag command definition contains a
linebreak before the command name. TPLugin matches a regexp against
single lines. It currently ignores line continuations.

For the moment, you could define a custom definition in
autoload/tplugin/autoload/ag.vim

call TPluginCommand('com! -bang -nargs=+ Ag', 'ag')

etc.

BTW you might want to consider asking the developer to move the
Complete function to autoload/ag.vim as ag#Complete, which would
facilitate the use with tplugin.

HTH

@blueyed
Copy link
Contributor Author

blueyed commented Nov 18, 2014

I've looked into this again (trying to combine tplugin's autoload facilities with NeoBundle).

I guess the problem here is that the :Ag command definition contains a linebreak before the command name.

That appears to be not an issue.

The problem here is that ag.vim checks with exists, which returns 3 for "3 matches several user commands", because tplugin only deletes the Ag command, but not the other ones defined (via autoload) for the plugin:

if !exists(":Ag")
  command -bang -nargs=+ -complete=customlist,ag#Complete
    \ Ag :call ag#Ag(<q-args>, 0, '<bang>')
endif

While the real fix is to check for != 2 in the plugin, I could imagine that tplugin should remove all commands of the plugin it autoloads.

I will provide a PR for this.

blueyed added a commit to blueyed/tplugin_vim that referenced this issue Nov 18, 2014
Having calles `s:RemoveAutoloads` with a specific cmd only would not
trigger deleting of all user commands later.

Fixes tomtom#9
blueyed added a commit to blueyed/ag that referenced this issue Nov 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants