Created
May 31, 2017 02:14
-
-
Save ethagnawl/7ed9852d896841f262c16ec4540e4920 to your computer and use it in GitHub Desktop.
vim background job demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" http://andrewvos.com/writing-async-jobs-in-vim-8 | |
function! BackgroundCommandClose(channel) | |
execute "cfile! " . g:backgroundCommandOutput | |
copen | |
unlet g:backgroundCommandOutput | |
endfunction | |
function! RunBackgroundCommand(command) | |
if !exists('g:backgroundCommandOutput') | |
let g:backgroundCommandOutput = tempname() | |
call job_start(a:command, {'close_cb': 'BackgroundCommandClose', 'out_io': 'file', 'out_name': g:backgroundCommandOutput}) | |
endif | |
endfunction | |
command! -nargs=+ -complete=shellcmd RunBackgroundCommand call RunBackgroundCommand(<q-args>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment