Thanks for all your work on this plugin - the Drush integration is great!

I'm wondering how difficult it would be to implement asynchronous execution of a Drush command.

For example, if you execute a long running Drush command (like `drush rebuild` or `drush sql-sync`), you have to wait for the command to finish before you see the output or can edit text in the current buffer.

It would be really great to see output from Drush as it happens (not all at once) and to be able to continue working while the Drush command is running.

CommentFileSizeAuthor
#4 asynchronous-drush-1997286-4.patch1.64 KBbenjifisher

Comments

benjifisher’s picture

Hm, that sounds hard.

Just brainstorming here, I guess we could run the command in the background and pipe the output to a temporary file, then open the file in a new buffer. Getting it to auto-update is a problem.

There may be some entirely different method that works on Windows. Something like start, right?

Why not just do this in a terminal window? Is your goal never to leave vim, or is it really useful to search the output from the drush command?

If you track me down at DrupalCon, we can try to work on this.

kostajh’s picture

Yes, this could just be done in a terminal window, but it would be nice to be able to stay in Vim.

Couple of things that may be relevant:

I won't be at DrupalCon unfortunately.

kostajh’s picture

Issue summary: View changes

It turns out that this is really simple with vim-dispatch. See https://github.com/kostajh/drupal.vim/commit/e5ec14e587982ecd39466d1c475...

benjifisher’s picture

Status: Active » Needs review
StatusFileSize
new1.64 KB

@kostajh:

Can we talk some time about merging the two forks of this project? If there is one thing I hate, it is duplication of effort, and extracting a patch from your GitHub project in order to apply it to this project is not a good workflow.

I started with your commit e5ec14e5 and made some changes:

  1. Instead of if ... else ... endif endfun I used if ... return endif ... endfun. Personal preference: I do not like large sections of conditional code.
  2. In order to avoid duplication, I moved the 'statusline' definition to the top of the function.
  3. I changed exe 'Dispatch'.' drush ' . a:command to exe 'Dispatch drush' a:command. It should really be execute (spelled out) for consistency.
  4. I commented out the line that sets 'statusline' in the vim-dispatch branch (see below).

I tested with :Drush pml and :Drush help. (First I installed vim-dispatch and restarted vim.) It seems to me that I still had to wait until the command was done before I could continue working. Is there some configuration I have to make for vim-dispatch to do what you want?

I commented out the 'statusline' setting because it seems to apply to the window in which I started instead of the window containing the drush output. That seems like a bug to me. Is there some way to set the status line on the quickfix window?

kostajh’s picture

@benjifisher I'm happy to to merge the changes I made back into this project. I had emailed you about 6 months ago but never heard back, and figured having my changes in GitHub would be better than a bunch of patches to my local plugin :-)

Are you using tmux? vim-dispatch won't do much for you otherwise. I'm on IRC as kostajh, send me a message and we can discuss merging.

rodrigoaguilera’s picture

I tried to test this patch

First I had no dispatch vim plugin, running a long drush task blocks vim until it ends.

Applied this patch and I got the same behavior.

Installed https://github.com/tpope/vim-dispatch
And when I run the drush long task I'm brought back to what I had in the terminal emulator. Then I go back to vim with and additional window open with the output of the command (with extra information about output with colors, rubish)

Also installed tmux but nothing changed from the previous behaviour.

I think it needs more explanation about what is expected from this change.

@kostajh:
I would be happy also to concentrate the efforts here. Appart from this feature do you have more improvements in your fork?
Can you open an issue for them?

kostajh’s picture

@rodrigoaguilera Yeah, you need to be using tmux and vim-dispatch for this feature to work. And, it really does work! You can run a long running task (e.g. drush ws --tail) and not have your editor blocked. I'm unpublishing my fork because I'm no longer using Vim - Emacs + evil-mode convert here :-) Good luck!

rodrigoaguilera’s picture

Status: Needs review » Reviewed & tested by the community

Ok

What I wasn't doing is running the session inside tmux. Now I see it in action.

benjifisher’s picture

Status: Reviewed & tested by the community » Fixed

I guess this does not really need documentation. If you have vim-dispatch installed, then probably you know to use it with tmux or similar. If you do not have it installed, then the patch does not do any harm.

  • benjifisher committed 8ca8e2d on 7.x-1.x authored by kostajh
    Issue #1997286 by benjifisher, kostajh, rodrigoaguilera: Asynchronous...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.