Search code examples
vimluaneovim

Difference between Vim's "job_start()" function and Neovim's "jobstart()" function?


I found an ancient Vim plug-in that looks to be useful to me: https://github.com/rolf007/multiplayer.vim.

Unfortunately, I was getting errors thrown by the job_start function used in a couple of the places. Apparently, that function does not exist. Since I use Neovim, I replaced job_start in the module with jobstart. Miraculously, it seemed to fix the error.

But I have no idea if jobstart is a drop in replacement. Seems odd that it would be given the Neovim strives to be a drop-in replacement for Vim.


Solution

    1. No, Neovim doesn't strive to be a drop-in replacement for Vim at all. Compatibility with Vim has never been a goal of the project.

      Moreover, Neovim's "job" feature came before Vim's so there is really no reason whatsoever to expect the two to be compatible in any way.

    2. As a quick look at their respective documentation would have told you, Neovim's :help jobstart() and Vim's :help job_start() have similar signatures but accept different options, which makes them mutually incompatible.

      The plugin in question appears to be calling job_start() two times:

      • One without options, which can be replaced with Neovim's jobstart() without side-effects,

      • One with options, which might be replaced with a straight jobstart() but you might have problems with the options. If the implementation of jobstart() is not very strict, then it will ignore the unknown option, if it is strict, then it will throw an error.

        That said, Neovim's :help on_stdout seems to be equivalent to Vim's :help out_cb in spirit, so changing the name of the option might be enough, if the way the callback function is implemented allows it.

        That callback function would be the ideal place for something to break.

      Note that it also calls :help job_stop(), which you will have to deal with as well so, no, simply doing :%s/job_start/jobstart won't be enough to port that plugin to Neovim.