Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

An Alternate Way To Run An External Async Command In Neovim

This is a draft for an alt way to run an external command. I don't use it, I use plenary. See post 2ngtllokpfsv for the way I use.

Here's an example of how to setup a Neovim plugin to make an external async call.

lua
local async_test_function = function()
  local output = ""
  local cmd = {'bash', '-c', 'sleep 2; echo "PING"'}
  vim.fn.jobstart(cmd, {
    on_stdout = function(j, d, e)
      output = output .. vim.fn.join(d)
      print(output)
    end
  })
end

- The docs say you can use ` [] ` as the first argument to ` jobstart() ` . That didn't work for me. That example is for a [TODO: Code shorthand span ] file which probably has something to do with it. I have yet to find one for .lua directly. This approach uses the [TODO: Code shorthand span ] and then calls it as the first argument instead.

code start

If Plenary didn't exist, this is what I'd use to run external commands asynchronously from Neovim