Imagine the following asynchronous job to convert a given file to odt :

let mdfile = 'testfile.md'
call jobstart (['bash', '-c', 'pandoc ' . mdfile . ' -s -f markdown -o test.odt'], {'on_exit': 'OnEvent'})

Is there a way to pass the mdfile variable to the OnEvent function ?


1 Answer 1


Have you tried partials?

{'on_exit': function('OnEvent', [parameters])}

This is what I do in lh-tags+lh-vim-lib to register things like: delete a temporary file and print a finished message on close_cb with vim -- I've never tried to use neovim.

  • Neovim fully supports partials.
    – Matt
    May 27, 2020 at 12:09
  • Thanx for the answer. But with your solution, how could I also pass the "data" parameter of the job to check whether it has succeded or not inside of the called function ? I know I could create another function called by the on_err event, but is this possible to do it in the same function as the one called by on_exit ?
    – Dupond
    May 27, 2020 at 12:57
  • Also, I've taken a look at :h partial, but I haven't understood how I could use a dictionary for my use case... Any help would be grately appreciated, thanx !
    – Dupond
    May 27, 2020 at 13:21
  • I cannot help you with neovim specificities regarding jobs. With Vim, I only register close_cb, and I check the result of jobinfo(). See my async job queue object in lh-vim-lib. May 27, 2020 at 19:59
  • Regarding partials, in vim, the most useful help is the one from function(). May 27, 2020 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.