问题
So now both vim and neovim support terminal emulators inside them (with the terminal command). (I use neovim.)
I often open a terminal inside vim and run some long running build/test command in it, I then close its window in order to save space for coding. I then have to check back on that terminal periodically to see if the command it ran has completed.
Is there a way vim can listen to terminal command completion (through interprocess communication or some other way) ?
That way I can automatically bring the terminal buffer to the foreground as soon as its command completes.
I know there are a bunch of async job plugins (for vim and neovim) that support such callback feature, eg: https://github.com/skywind3000/asyncrun.vim and others. But based on my research they all have all/some of the following limitations:
- They don't support multiple simultaneous background jobs.
- They use quickfix command to show the result. Since there's only 1 quickfix window, the output often gets messed up (If I use some other plugin in the meantime that writes to quickfix window.). (Using location list won't really help as well as it's still one per window and its local to window). Plus it would need plugin code modification.
- Being able to use native terminal emulator instead of these plugins would create better experience (eg: some commands produce colored output).
来源:https://stackoverflow.com/questions/64057107/vim-neovim-callback-on-terminal-command-completion