[vim/vim] Error out on :command with -complete but without -nargs (#8544)

60 views
Skip to first unread message

Martin Tournoij

unread,
Jul 10, 2021, 9:40:55 PM7/10/21
to vim/vim, Subscribed

Previously this would kind-of work: if there's nothing on the cmdline it
works, but if you type anything and press Tab you get a literal tab
character.

This can be confusing, especially if you use -complete=custom, since you
might be thinking you somehow implemented this wrong.

Fixes #8541


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/8544

Commit Summary

  • Error out on :command with -complete but without -nargs

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Martin Tournoij

unread,
Jul 10, 2021, 10:38:58 PM7/10/21
to vim/vim, Push

@arp242 pushed 1 commit.

  • 50cdfb7 Error out on :command with -complete but without -nargs


You are receiving this because you are subscribed to this thread.

View it on GitHub or unsubscribe.

codecov[bot]

unread,
Jul 11, 2021, 6:12:41 AM7/11/21
to vim/vim, Subscribed

Codecov Report

Merging #8544 (ab3619e) into master (482d2f3) will decrease coverage by 87.53%.
The diff coverage is 0.00%.

Current head ab3619e differs from pull request most recent head 50cdfb7. Consider uploading reports for the commit 50cdfb7 to get more accurate results
Impacted file tree graph

@@             Coverage Diff             @@

##           master    #8544       +/-   ##

===========================================

- Coverage   90.03%    2.49%   -87.54%     

===========================================

  Files         150      148        -2     

  Lines      168173   162914     -5259     

===========================================

- Hits       151413     4066   -147347     

- Misses      16760   158848   +142088     
Flag Coverage Δ
huge-clang-none ?
huge-gcc-none ?
huge-gcc-testgui ?
huge-gcc-unittests 2.49% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/usercmd.c 0.00% <0.00%> (-94.78%) ⬇️
src/float.c 0.00% <0.00%> (-98.91%) ⬇️
src/digraph.c 0.00% <0.00%> (-97.78%) ⬇️
src/gui_gtk_f.c 0.00% <0.00%> (-97.54%) ⬇️
src/match.c 0.00% <0.00%> (-97.13%) ⬇️
src/crypt_zip.c 0.00% <0.00%> (-97.06%) ⬇️
src/sound.c 0.00% <0.00%> (-97.00%) ⬇️
src/sha256.c 0.00% <0.00%> (-96.94%) ⬇️
src/evalbuffer.c 0.00% <0.00%> (-96.83%) ⬇️
src/cmdhist.c 0.00% <0.00%> (-96.63%) ⬇️
... and 137 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 482d2f3...50cdfb7. Read the comment docs.

Bram Moolenaar

unread,
Jul 11, 2021, 8:29:06 AM7/11/21
to vim/vim, Subscribed

Closed #8544 via de69a73.

Shane-XB-Qian

unread,
Jul 11, 2021, 10:08:05 AM7/11/21
to vim/vim, Subscribed

perhaps you are waiting some complains, then here we go:
@tpope your fugitive has some -nargs=0 and with -complete, now broken... :-)

lacygoill

unread,
Jul 11, 2021, 10:26:14 AM7/11/21
to vim/vim, Subscribed

Yes, one of the most popular plugins out there (vim-fugitive) has 4 commands defined with -nargs=0 and -complete. It's broken by this patch:

vim -Nu NONE +'command -nargs=0 -complete=arglist Comd eval 0'
E1208: -complete used without -nargs

I don't know whether it makes sense to have -nargs=0 and -complete at the same time, but I do know that we will receive a lot of complaints.

Martin Tournoij

unread,
Jul 11, 2021, 10:28:37 AM7/11/21
to vim/vim, Subscribed

It would help if that plugin would fix it; not many people run the latest master and many distros are weeks, months, or years behind.

Bryan Bugyi

unread,
Jul 11, 2021, 11:54:39 AM7/11/21
to vim/vim, Subscribed

@chemzqm FYI, the coc.nvim plugin is also broken by this patch.

Tim Pope

unread,
Jul 11, 2021, 11:56:32 AM7/11/21
to vim/vim, Subscribed

Easy fix, but your argument cuts both ways: Many people update Vim regularly alongside their distro, but never bother to manually update their plugins.

lacygoill

unread,
Jul 11, 2021, 12:01:58 PM7/11/21
to vim/vim, Subscribed

Many people update Vim regularly alongside their distro, but never bother to manually update their plugins.

True, so we probably need to make an exception for -nargs=0, and handle the latter as if it was -nargs=1; at least for this particular check. Otherwise, we will get too many complaints from various popular plugins.

Although, maybe the check could be more strict in Vim9 script.

Bram Moolenaar

unread,
Jul 11, 2021, 12:42:46 PM7/11/21
to vim/vim, Subscribed

Well, we could make it a warning. The the plugin won't break and there is a hint that something is wrong.

Gary Johnson

unread,
Jul 11, 2021, 1:18:02 PM7/11/21
to reply+ACY5DGHFXJYDYCHXG2...@reply.github.com, vim...@googlegroups.com
On 2021-07-11, Bram Moolenaar wrote:
> Well, we could make it a warning. The the plugin won't break and there is a
> hint that something is wrong.

Would that mean that I would see warning messages every time
I started Vim, and have to hit Enter to clear those messages?

Regards,
Gary

vim-dev ML

unread,
Jul 11, 2021, 1:18:22 PM7/11/21
to vim/vim, vim-dev ML, Your activity

Shane-XB-Qian

unread,
Jul 11, 2021, 1:30:04 PM7/11/21
to vim/vim, vim-dev ML, Comment

pls Do Not Forget we may be Not Able to Find the maintainer of some classic plugins anymore.........................
// in short, This is terrible!


You are receiving this because you commented.

Bram Moolenaar

unread,
Jul 11, 2021, 1:33:12 PM7/11/21
to vim/vim, vim-dev ML, Comment

Well, you can ignore them or fix the problem.


You are receiving this because you commented.

Dominique Pellé

unread,
Jul 11, 2021, 1:35:12 PM7/11/21
to vim/vim, vim-dev ML, Comment

pls Do Not Forget we may be Not Able to Find the maintainer of some classic plugins anymore

Do we know which plugins have this error (now warning)? It may not be so bad if there are very few plugins affected and if the change helps to detect issues. I use several plugins and I only noticed the error with the fugitive plugin (which is very popular). It was fixed immediately when did PlugUpdate.


You are receiving this because you commented.

Shane-XB-Qian

unread,
Jul 11, 2021, 1:38:26 PM7/11/21
to vim/vim, vim-dev ML, Comment

Well, you can ignore them or fix the problem.

supposed you were answering to Gary's question, or i knew i may can fork or local edit some, but mostly such cannot replace the original/owner's role(ownership) of his/her repo, not a good solution.

// anyway, compatible looks was vim always insisted working style. i think we should keep it so...


You are receiving this because you commented.

lacygoill

unread,
Jul 11, 2021, 1:39:55 PM7/11/21
to vim/vim, vim-dev ML, Comment

Would that mean that I would see warning messages every time
I started Vim, and have to hit Enter to clear those messages?

I've just checked and yes, you need to hit Enter. I think the best way to handle the issue would be to log the warning (which can be read later at any time with :messages) without interrupting Vim on startup, and forcing the user to press Enter to get rid of the message.


You are receiving this because you commented.

lacygoill

unread,
Jul 11, 2021, 1:41:56 PM7/11/21
to vim/vim, vim-dev ML, Comment

Maybe give the warning only if 'verbose' is set to some arbitrary value greater than the default (which is 0).


You are receiving this because you commented.

Martin Tournoij

unread,
Jul 11, 2021, 9:39:06 PM7/11/21
to vim/vim, vim-dev ML, Comment

A warning in :messages is pretty invisible, and even more so with :verbose.

The entire reason I looked at this is because -complete=custom,.. didn't work and that I thought the error was in my custom function, while it turned out that I just forgot -nargs; I lost a good 20-30 minutes on this. Silly on my part, but I'm probably not the first one.

No option is perfect here, but a warning seems like a decent compromise unless there's a whole bunch of other plugins that break (and it's not clear to me that's the case).


You are receiving this because you commented.

Reply all
Reply to author
Forward
0 new messages