1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 15:00:06 +08:00
SpaceVim/bundle/plenary.nvim/lua/plenary/run.lua

29 lines
552 B
Lua
Raw Normal View History

2022-05-16 22:20:10 +08:00
local floatwin = require "plenary.window.float"
local run = {}
run.with_displayed_output = function(title_text, cmd, opts)
local views = floatwin.centered_with_top_win(title_text)
local job_id = vim.fn.termopen(cmd)
local count = 0
while not vim.wait(1000, function()
return vim.fn.jobwait({ job_id }, 0)[1] == -1
end) do
vim.cmd [[normal! G]]
count = count + 1
if count == 10 then
break
end
end
vim.fn.win_gotoid(views.win_id)
vim.cmd [[startinsert]]
return views.bufnr, views.win_id
end
return run