Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 208
iamthelabhras Avatar asked Jul 26 '21 15:07

iamthelabhras


4 Answers

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.

like image 128
romainl Avatar answered Oct 23 '22 03:10

romainl


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.

like image 34
Aaron Miller Avatar answered Oct 23 '22 04:10

Aaron Miller


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!

like image 2
Vittore Marcas Avatar answered Oct 23 '22 04:10

Vittore Marcas


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
like image 1
Wildsky Avatar answered Oct 23 '22 04:10

Wildsky