Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-x committed Dec 1, 2024
1 parent 3f5645c commit 37f6219
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions lua/go/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ local run = function(cmd, opts, uvopts)
end
end

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

local combine_output = ''
if output_buf ~= '' or output_stderr ~= '' then
-- stdout was handled by update_chunk
-- lets handle stderr here
if output_stderr ~= '' then
-- some commands may output to stderr instead of stdout
combine_output = (output_buf or '') .. '\n' .. (output_stderr or '')
combine_output = util.remove_ansi_escape(combine_output)
combine_output = vim.trim(combine_output)
output_stderr = util.remove_ansi_escape(output_stderr)
output_stderr = vim.trim(output_stderr)
log('output_stderr', output_stderr)

local lines = util.handle_job_data(vim.split(output_stderr, '\n'))
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)
end)
end
end

local combine_output = output_buf .. '\n' .. output_stderr
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
log('on_exit returned ', onexit_output)
end

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
log('command finished with error code: ', code, signal)
end
log('command finished: ', locopts, lines)
if #lines > 0 then
vim.schedule(function()
vim.fn.setloclist(0, {}, ' ', locopts)
util.info('run lopen to see output')
end)
end
end
_GO_NVIM_CFG.on_exit(code, signal, output_buf)

_GO_NVIM_CFG.on_exit(code, signal, combine_output)
end
)
_GO_NVIM_CFG.on_jobstart(cmd)
Expand Down

0 comments on commit 37f6219

Please sign in to comment.