Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running tasks sequentially #21

Open
Shatur opened this issue Mar 17, 2020 · 16 comments
Open

Running tasks sequentially #21

Shatur opened this issue Mar 17, 2020 · 16 comments

Comments

@Shatur
Copy link
Contributor

Shatur commented Mar 17, 2020

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 :)

@skywind3000
Copy link
Owner

skywind3000 commented Mar 17, 2020

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.

@Shatur
Copy link
Contributor Author

Shatur commented Mar 17, 2020

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.

@skywind3000
Copy link
Owner

skywind3000 commented Mar 17, 2020

It is difficult to chain tasks with different output and pos together.

@Shatur
Copy link
Contributor Author

Shatur commented Mar 17, 2020

Maybe you don't need to chain output of such tasks? :AsyncTask first second could works as :AsyncTask first, wait for finish, :AsyncTask second.

@skywind3000
Copy link
Owner

skywind3000 commented Mar 17, 2020

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.

@Shatur
Copy link
Contributor Author

Shatur commented Mar 17, 2020

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?

@skywind3000
Copy link
Owner

Sad to say it is impossible.

And a work around is to concatenate two commands with $$ in one task.

@skywind3000
Copy link
Owner

s/$$/&&/g

@Shatur
Copy link
Contributor Author

Shatur commented Mar 18, 2020

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>

@skywind3000
Copy link
Owner

A big refactor is required for this.

@Shatur
Copy link
Contributor Author

Shatur commented Mar 18, 2020

Do you like the idea in general? If yes, I think that is possible to think about simpler syntax.

@skywind3000
Copy link
Owner

It is a good idea.

@Shatur
Copy link
Contributor Author

Shatur commented Mar 18, 2020

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?

@skywind3000
Copy link
Owner

That's even more complex, because asynctasks.vim needs to parse dependency

@Shatur
Copy link
Contributor Author

Shatur commented Mar 19, 2020

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?

@IngoMeyer441
Copy link

IngoMeyer441 commented Jan 19, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants