Skip to content

Commit

Permalink
output progress messages from stdout
Browse files Browse the repository at this point in the history
This is now okay, due to the previous commit (a25ecf3), so these messages will now not stack when using vim-notify.

these show only one message at a time. For another example of a plugin which shows progress messages like this, see nvim-treesitter/nvim-treesitter.
  • Loading branch information
aarondill committed Jan 12, 2024
1 parent 78075fc commit f910a3b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lua/tabnine/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ local cmd_str = table.concat(vim.tbl_map(vim.fn.shellescape, { cmd, unpack(args)
local function run_build(callback)
print(("Starting tabnine-nvim build script: `%s`"):format(cmd_str))
local stderr = assert(uv.new_pipe())
local stdout = assert(uv.new_pipe())

local handle, pid = uv.spawn(
cmd,
{
args = args,
stdio = { nil, nil, stderr },
stdio = { nil, stdout, stderr },
cwd = utils.script_path(),
},
vim.schedule_wrap(function(code)
Expand Down Expand Up @@ -56,6 +57,16 @@ local function run_build(callback)
return vim.api.nvim_err_writeln(("`%s`: ERROR: %s"):format(cmd_str, data))
end)
)
uv.read_start(
stdout,
vim.schedule_wrap(function(err, data)
assert(not err, err)
if not data then return end
data = data:gsub("%s+$", ""):gsub("^%s+", "") -- remove trailing and leading whitespace
if data == "" then return end
return print(("`%s`: %s"):format(cmd_str, data))
end)
)
return pid, nil
end
local function run_build_sync()
Expand Down

0 comments on commit f910a3b

Please sign in to comment.