I want to write a wrapper to a plugin's function, but it uses varargs (...
). How can I pass the same arguments my function receives to the plugin's function?
Example:
function! PluginInterface(...)
for i in a:000
echo i
endfor
endfunction
function! MyInterface(...)
echo a:1 . ' is great'
call PluginInterface(a:000)
endfunction
echo '>> Their call'
call PluginInterface('hello', 'world')
echo '>> My call'
call MyInterface('hello', 'world')
Instead of calling the function directly (call PluginInterface(a:000)
), use call()
:
call call("PluginInterface", a:000)
call call(function("PluginInterface"), a:000)
(That looks strange, but call()
is a function so you still have to prefix it with :call
or let x =
or something that accept an expr
.)
See :help call()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With