I am currently working on a neovim plugin and have a question that relates to job-control/terminal commands api in Vim/Neovim:
I have a command that needs to be executed in a terminal buffer that has been pre-created with the command: vim.cmd(':term')
.
After its creation, I now send a command to this terminal with vim.api.nvim_chan_send(channel_number, 'long_running_proc.exe\r')
, where long_running_proc is a long running process.
The long_running_proc
does finish after sometime, but I want to query the status of this long_running_proc
command that is currently running in the terminal emulator(i.e. if it has finished or is still running or failed).
My intention is to keep the same terminal buffer running and reuse it for other long_running_proc
commands after this, but I want to issue these commands, only after the existing command has finished.
Example Use case:
I want to send a command Start Sleep -Seconds 10
to Powershell, and immediately the Start Sleep -Seconds 100
command. But I do not want to send this unless the previous command has finished execution. If I do send the second command, I need it to fail and return with an error something like: "A command is already running! cannot send another command"
Is there a way to do this?
PS: I am currently using the neovim api, but I think there is a significant overlap between both, hence the two tags vim and neovim.