skywind3000 / asyncrun.vim

:rocket: Run Async Shell Commands in Vim 8.0 / NeoVim and Output to the Quickfix Window !!
https://www.vim.org/scripts/script.php?script_id=5431
MIT License
1.84k stars 109 forks source link

AsyncStop followed by AsyncRun doesn't work #216

Open solotim opened 3 years ago

solotim commented 3 years ago

Hi, Thanks for the awesome plugin. I want to use to kick off background command whenever the file is saved. I created autocmd below, but if not "sleep 1" after AsyncStop the command doesn't work. I.e the running job is stopped but rerun doesn't start. Could you let me know the correct setup here? Thanks.

autocmd BufWritePost *.cc,*.h call MyMake()
function MyMake()
    if g:asyncrun_status == 'running'
        AsyncStop
        sleep 1
    endif
    AsyncRun mymake
    copen 40
endfunction