Is it possible to let Vim's omnicppcomplete automatically close argument lists for functions or methods that do not take any arguments?
For example, assuming v is an STL vector, when auto completing v.clear(), we end up with:
v.clear(
It would be nice if the closing parenthesis would be automatically added. Is this possible?
It looks like it should be possible: I'm not sure whether I have the latest version of the omnicppcomplete script, but in my
autoload/omni/cpp/complete.vim, there is a function calleds:ExtendTagItemToPopupItem. In this function, there is:After the line (#165 in my version)
let szItemWord .= '(', add:That should do the trick (although I don't use C++ much, so I haven't tested it extensively). It basically checks whether the "signature" of the function contains "
()" as opposed to (for example) "(int *major, int *minor)". If the brackets are empty, it adds a closing brace.It could probably be improved by changing
'()'to'(\s*\(void\)\?\s*)'for completeness: this would check for "()", "( )", "(void)", "( void )" etc.