I have the following Lua function:
local function submit_diff(diff_msg_file)
vim.fn.termopen("arc diff HEAD^ -F " .. diff_msg_file, {
on_exit = function(_, exit_code, _)
if exit_code == 0 then
vim.loop.fs_unlink(diff_msg_file)
end
end,
})
end
This does almost everything I want. It:
- Runs the command
arc diff
with the appropriate arguments - I can delete the file speficied as an argument if the terminal command exits succesfully
The one problem is that no window is opened. The command being run is interactive, so I can't see what's going on since the buffer created by termopen
doesn't seem to automatically create and attach to its own window.
Is there a way for me to either find the buffer created by termopen and then create a window to attach it to, or call termopen in such a way a window is created with the buffer attach, or should I be using something other than termopen?
nvim_buf_call
to calltermopen
inside the callback (sure you need to load thebuf
you passing intonvim_buf_call
into a window beforehand. (I was just solving a similar problem and got an answer.)