chore(build): streaming stdout (#511)
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
parent
1e43122cac
commit
b48b6b7afd
@ -66,9 +66,24 @@ M.build = function(opts)
|
||||
error("Unsupported operating system: " .. os_name, 2)
|
||||
end
|
||||
|
||||
local job = vim.system(cmd, { text = true }):wait()
|
||||
|
||||
return vim.tbl_contains({ 0 }, job.code) and true or false
|
||||
---@type integer
|
||||
local code
|
||||
vim.system(cmd, {
|
||||
text = true,
|
||||
stdout = function(_, data)
|
||||
if data then vim.schedule(function() vim.api.nvim_echo({ { data, "Normal" } }, false, {}) end) end
|
||||
end,
|
||||
stderr = function(err, _)
|
||||
if err then vim.schedule(function() vim.api.nvim_echo({ { err, "ErrorMsg" } }, false, {}) end) end
|
||||
end,
|
||||
}, function(obj)
|
||||
if vim.tbl_contains({ 0 }, obj.code) then
|
||||
code = obj.code
|
||||
else
|
||||
vim.api.nvim_echo({ { "Build failed with exit code: " .. obj.code, "ErrorMsg" } }, false, {})
|
||||
end
|
||||
end)
|
||||
return code
|
||||
end
|
||||
|
||||
---@param question? string
|
||||
|
@ -73,6 +73,7 @@ H.keymaps = function()
|
||||
vim.keymap.set({ "n", "v" }, "<Plug>(AvanteAsk)", function() require("avante.api").ask() end, { noremap = true })
|
||||
vim.keymap.set("v", "<Plug>(AvanteEdit)", function() require("avante.api").edit() end, { noremap = true })
|
||||
vim.keymap.set("n", "<Plug>(AvanteRefresh)", function() require("avante.api").refresh() end, { noremap = true })
|
||||
vim.keymap.set("n", "<Plug>(AvanteBuild)", function() require("avante.api").build() end, { noremap = true })
|
||||
vim.keymap.set("n", "<Plug>(AvanteToggle)", function() M.toggle() end, { noremap = true })
|
||||
vim.keymap.set("n", "<Plug>(AvanteToggleDebug)", function() M.toggle.debug() end)
|
||||
vim.keymap.set("n", "<Plug>(AvanteToggleHint)", function() M.toggle.hint() end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user