How to use lua vim object inside c?

I want to use the lua vim object inside c.
Example of how I would want to use it:

lua_State *L=get_neovim_lua_instance();
//or
//lua_State *L=get_remote_neovim_lua_instance(neovim_instance);
lua_getglobal(L,"vim");
lua_getfield(L,-1,"cmd");
lua_pushstring(L,"quit");
lua_pcall(L,1,1,0);