asynctasks.vim
asynctasks.vim copied to clipboard
Running tasks sequentially
Is it possible to run tasks sequentially? For example, in most IDEs, when a project starts, compilation occurs first. It would be convenient to assign build + run to a single key.
P.S. Sorry for a lot of issues :)
It is not a simply task, which would significantly increase the complexity. Many corner cases need to be handled.
No problem for issues, they let me know how to polish this plugin.
It is not a simply task, which would significantly increase the complexity. Many corner cases need to be handled.
Understand. Will you try to implement it in future? It would be great to be able to pass multiple tasks to :AsyncTask for sequential execution.
It is difficult to chain tasks with different output and pos together.
Maybe you don't need to chain output of such tasks? :AsyncTask first second could works as :AsyncTask first, wait for finish, :AsyncTask second.
Some kinds of tasks (including user defined runners) have no exit callback to notify AsyncTask to proceed next one.
Some tasks will open a new split/tab, if people are editing in insert mode, opening a new split/tab is really unexpected.
Some tasks will open a new split/tab, if people are editing in insert mode, opening a new split/tab is really unexpected.
But if the user created a task that does this, this is the user's problem, I think.
Some kinds of tasks (including user defined runners) have no exit callback to notify AsyncTask to proceed next one.
Bad to hear :( So, it's not possible?
Sad to say it is impossible.
And a work around is to concatenate two commands with $$ in one task.
s/$$/&&/g
Maybe it would be possible to get parameters from other tasks? It could solve the problem. Something like this can allow to execute build + run and only build:
[project-build]
command=cd ../build-$(VIM_PRONAME)-$(VIM_PROFILE) && cmake --build .
cwd=<root>
[project-run]
command=$(project-build:command) && ./my-executable
cwd=<root>
A big refactor is required for this.
Do you like the idea in general? If yes, I think that is possible to think about simpler syntax.
It is a good idea.
Okay :) Getting parameters from other tasks is very flexible and generic solution. Maybe would be simpler to add the ability to specify commands that will be concatenated? For example:
[project-build]
command=cd ../build-$(VIM_PRONAME)-$(VIM_PROFILE) && cmake --build .
cwd=<root>
[project-run]
depends=project-build
command=cd ../build-$(VIM_PRONAME)-$(VIM_PROFILE) && ./my-executable
cwd=<root>
It less flexible, but maybe it would be simpler to implement?
That's even more complex, because asynctasks.vim needs to parse dependency
Hm... What if use :AsyncTask first-task second-task with concatenation under the hood and disallow user to specify different output and pos in running tasks?
This will have some limitations for user tasks, but maybe it will be easier?
I use the following workaround to build and run a file:
let s:asynctask_build_filetypes = ['c', 'cpp', 'rust']
function! s:asynctask_call_after_build_file()
augroup asyntask_file_build_finished
autocmd!
augroup END
AsyncTask file-run
endfunction
function! s:asynctask_build_and_run_file()
if index(s:asynctask_build_filetypes, &filetype) >= 0
augroup asyntask_file_build_finished
autocmd!
autocmd User AsyncRunStop call s:asynctask_call_after_build_file()
augroup END
AsyncTask file-build
else
call s:asynctask_call_after_build_file()
endif
endfunction
command! AsyncTaskBuildAndRunFile call <SID>asynctask_build_and_run_file()
nnoremap <S-F7> :AsyncTaskBuildAndRunFile<CR>
Pressing <Shift-F7> builds an executable and runs it, after the build was completed. It uses the AsyncRunStop autocommand which is triggered after a task has been completed.