'Chronic ripgrep / vim Plugin Error on Load: "-complete Used Without -nargs"?

I recently added ripgrep to my list of vim plugins and, immediately after installation, I began receiving this error message whenever I loaded up vim:

Error detected while processing /Users/my_macbook/.vim/plugged/vim-ripgrep/plugin/vim-ripgrep.vim:

line  149: E1208: -complete used without -nargs
Press ENTER or type command to continue

Opening the offending file and reviewing lines 148-149 reveals:

148 command! -nargs=* -complete=file Rg :call s:Rg(<q-args>)
149 command! -complete=file RgRoot :call s:RgShowRoot()

I am well & truly out of my depth here, especially considering that this error was generated by simply installing the plugin; I've made 0 changes to the underlying file (vim-ripgrep.vim).

Has anyone encountered a similarly chronic error after installing ripgrep and, if so, how did you resolve it?



Solution 1:[1]

Congratulations, you have found a bug in a FOSS program. Next step is to either notify the maintainer via their issue tracker or, if you know how to fix it, submit a patch.

Case in point, the author assigns a completion method, -complete=file, but custom commands like :RgRoot don't accept arguments by default so the command makes no sense as-is: you can't complete arguments if you can't pass arguments.

It only needs a -nargs=*, like its upstairs neighbour, :Rg, to work properly and the error message is pretty clear about it:

line  149: E1208: -complete used without -nargs

See :help -complete, :help -nargs, and more generally, :help user-commands.

Solution 2:[2]

As the other answer stated, it is a bug in this plugin. There is a currently open pull request to fix this: https://github.com/jremmen/vim-ripgrep/pull/58 Unfortunately, the repository is currently unmaintained, so it is unlikely to be merged any time soon. This active forks page may help you identify a new maintainer.

Until there is a new maintainer for vim-ripgrep, I suggest checking out that branch in your ~/.vim/plugged/vim-ripgrep directory and reopening vim.

Solution 3:[3]

If you are using vim-plug, try to change

Plug "jremmen/vim-ripgrep"

to

Plug "miyase256/vim-ripgrep", {'branch': 'fix/remove-complete-from-RgRoot'}

Here are detail steps:

  1. comment Plug "jremmen/vim-ripgrep"
  2. :PlugClean
  3. add Plug "miyase256/vim-ripgrep", {'branch': 'fix/remove-complete-from-RgRoot'}
  4. :PlugInstall

Solution 4:[4]

I met the functionally same error on VIM plugins while using vim ~/.vimrc.

My met error liking yours:

Error detected while processing /Users/my_macbook/.vim/plugged/vim-ripgrep

/plugin/vim-ripgrep.vim:

I fixed the upstairs with the below:

cd /Users/my_macbook/.vim/plugged/vim-ripgrep/plugin/

git pull --rebase

END!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2
Solution 3 Wildsky
Solution 4 Vittore Marcas