add update_chunk for runner

pull/230/head
ray-x 2 years ago
parent 1aef2d60bd
commit 737223c999

@ -17,9 +17,21 @@ function M.watch(args)
update_buffer = true,
on_exit = function()
vim.schedule(function()
utils.restart()
vim.notify('watch stopped')
end)
end,
on_chunk = function(err, lines)
if err then return end
for _, line in ipairs(lines) do
if line:match('Errors') then
vim.notify(vfn.join(lines, ', ' ), vim.lsp.log_levels.ERROR)
return
elseif line:match('PASS') or line:match('DONE') then
vim.notify(line, vim.lsp.log_levels.INFO)
end
end
end
}
runner.run(cmd, opts)
return cmd, opts

@ -40,8 +40,9 @@ local run = function(cmd, opts)
vim.notify('error ' .. tostring(err) .. vim.inspect(chunk or ''), vim.lsp.log_levels.WARN)
end)
end
local lines = {}
if chunk then
local lines = {}
for s in chunk:gmatch('[^\r\n]+') do
table.insert(lines, s)
end
@ -61,9 +62,19 @@ local run = function(cmd, opts)
vim.fn.setloclist(0, {}, ' ', locopts)
end)
end
return lines
end
local update_chunk = function(err, chunk)
local lines
if opts.update_chunk then
lines = opts.update_chunk(err, chunk)
else
lines = update_chunk_fn(err, chunk)
end
if opts.on_chunk and lines then
opts.on_chunk(err, lines)
end
end
local update_chunk = opts.update_chunk or update_chunk_fn
log('job:', cmd, job_options)
handle, _ = uv.spawn(
cmd,

Loading…
Cancel
Save