Let's say there is a vimscript function that takes a dictionary as a parameter. In vimscript, it is called like this:
call Vote({'name':'Phil Collins', 'band':'Genesis'})
I'm interested in what that function call (not the function itself) looks like in lua. The following statements work, but I wonder if there's a better, more lua-like way.
vim.cmd("call Vote({'name':'Neil Peart', 'band':'Rush'})")
vim.cmd.call("Vote({'name':'Larnell Lewis', 'band':'Snarky Puppy'})")
:h vim.cmd()
shows there is an args
key that can be used. Let's try that. This works, but it's even messier:
vim.cmd.call {args={"Vote({'name':'Ringo Starr', 'band':'Beatles'})"} }
I'd like to split that long string into a function name and its parameter, reformatted as a lua array. This doesn't work:
vim.cmd.call {args={"Vote", {name='Joe Morello', band='Dave Brubeck Quartet'}}}
E5108: Error executing lua [string ":lua"]:1: Invalid command arg: expected valid type, got Dict
stack traceback:
[C]: in function 'call'
[string ":lua"]:1: in main chunk
which leads me to believe that args
can only apply to call
, and not also to the Vote
function inside of call
. Is my observation correct, or is there a way to do this that I'm not seeing?