local M = {} function M.jobstart(cmd) local output = {} local function on_event(job_id, data, event) if event == 'stdout' or event == 'stderr' then if data then vim.list_extend(output, data) end end if event == 'exit' then vim.fn.setqflist({}, ' ', { title = cmd, lines = output, }) vim.api.nvim_command('doautocmd QuickFixCmdPost') end end local job_id = require('spinner.job').jobstart(cmd, { on_stdout = on_event, on_stderr = on_event, on_exit = on_event, stdout_buffered = true, stderr_buffered = true, }) return job_id end function M.make(args) local args = args or {} local makeprg = vim.opt.makeprg:get() local cmd = vim.split(vim.fn.expandcmd(makeprg), ' ') table.foreach(args, function(_, v) table.insert(cmd, v) end) return M.jobstart(cmd) end function M.sh(cmd) local cmd = {vim.env.SHELL, '-c', cmd} return M.jobstart(cmd) end return M