Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-x committed Dec 1, 2024
1 parent 2eedd5d commit c6d5ca2
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions lua/go/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ local run = function(cmd, opts, uvopts)
locopts.efm = opts.efm
end
log(locopts)
if opts.setloclist ~= false then
vim.schedule(function()
vim.fn.setloclist(0, {}, 'a', locopts)
vim.notify('run lopen to see output', vim.log.levels.INFO)
end)
end
end
return lines
end
local update_chunk = function(err, chunk)
Expand Down Expand Up @@ -106,6 +108,7 @@ local run = function(cmd, opts, uvopts)
end
end

output_stderr = ''
handle, _ = uv.spawn(
cmd,
{ stdio = { stdin, stdout, stderr }, cwd = uvopts.cwd, args = job_options.args },
Expand Down Expand Up @@ -141,25 +144,36 @@ local run = function(cmd, opts, uvopts)
end)
end

-- stdout was handled by update_chunk
-- lets handle stderr here
if output_stderr ~= '' then
local combine_output = ''
if output_buf ~= '' or output_stderr ~= '' then
-- some commands may output to stderr instead of stdout
output_stderr = util.remove_ansi_escape(output_stderr)
output_stderr = vim.trim(output_stderr)
log('output_stderr', output_stderr)
combine_output = (output_buf or '') .. '\n' .. (output_stderr or '')
combine_output = util.remove_ansi_escape(combine_output)
combine_output = vim.trim(combine_output)
end
if opts and opts.on_exit then
local onexit_output = opts.on_exit(code, signal, combine_output)
if not onexit_output then
return
else
combine_output = onexit_output
end
end

local lines = util.handle_job_data(vim.split(output_stderr, '\n'))
if code ~= 0 or signal ~= 0 or output_stderr ~= '' then
local lines = util.handle_job_data(vim.split(combine_output, '\n'))
local locopts = {
title = vim.inspect(cmd),
lines = lines,
}
if opts.efm then
locopts.efm = opts.efm
end
log('command finished: ', locopts, lines)
if #lines > 0 then
vim.schedule(function()
local locopts = {
title = vim.inspect(cmd),
efm = opts.efm,
lines = lines,
}

log('job data lines:', locopts)
vim.fn.setloclist(0, {}, 'a', locopts)
vim.fn.setloclist(0, {}, ' ', locopts)
util.info('run lopen to see output')
end)
end
end
Expand Down

0 comments on commit c6d5ca2

Please sign in to comment.