Open sys9kdr opened 1 year ago
FWIW, I have implemented this in my abstraction of spawn. Feel free to yoink this for plenary. Its basically just making everything async and "waiting" until a vim.loop.timer
fires to kill the running job if its still running.
In my case, I use a wrapper to kill jobs by timeout.
wrapFunc = function(someFuncReturnPid, timeout)
timeout = timeout or 5000
local pid = someFuncReturnPid
local timer = vim.loop.new_timer()
timer:start(timeout, 0, function()
vim.loop.kill(pid)
print('job timeout')
end)
end
I think that wrapper approach is redundant. So I want a timeout option.
Job:sync
already has a timeout: https://github.com/nvim-lua/plenary.nvim/blob/master/lua/plenary/job.lua#L451
Wouldn't it be more convenient to have timout in the job
itself? I don't like using sync
because of waiting time.
Commands in plenary.nvim's job sometimes take a long time to resolve, which can be frustrating for users. To address this, I propose adding a timeout option to the plugin's job feature. This would allow users to set a timeout for commands and automatically quit the command with an error message if it takes too long to execute.