sponsor Vim development Vim logo Vim Book Ad

AsyncCommand : Execute commands and have them send their result to vim when they complete

 script karma  Rating 99/30, Downloaded by 5105  Comments, bugs, improvements  Vim wiki

created by
David Briscoe
 
script type
utility
 
description
AsyncCommand allows you to execute shell commands without waiting for them
to complete. When the application terminates, its output can be loaded into
a vim buffer. AsyncCommand is written to be compatible with Windows and
Linux (tested on Win7 and Ubuntu 11.04).

Currently three types of commands are supported:

AsyncShell
    run any program and load results in a split
AsyncGrep
    grep for files and load results in quickfix
AsyncMake
    run make and load results in quickfix
AsyncCscopeFindSymbol, AsyncCscopeFindCalls, AsyncCscopeFindX
    cscope commands

You can define your own commands commands by following the same format:
Define a launch function that passes the external command and result handler
(like asynchandler#quickfix) to asynccommand#run. You can use the handlers in
autoload/asynchandler.vim or define your own.

Example:

    function! AsyncHello(query)
        " echo hello and the parameter
        let hello_cmd = "echo hello ".a:query
        " just load the file when we're done
        let vim_func = asynchandler#split()
    
        " call our core function to run in the background and then load the
        " output file on completion
        call asynccommand#run(hello_cmd, vim_func)
    endfunction

Note that cscope functions require these variables:
  let g:cscope_database = **full path to cscope database file**
  let g:cscope_relative_path = **folder containing cscope database file**
These variables can be set by tagfilehelpers.vim -- https://github.com/pydave/daveconfig/blob/master/multi/vim/.vim/plugin/tagfilehelpers.vim


Please report bugs to https://github.com/pydave/AsyncCommand/issues
 
install details
Unzip to ~/.vim/ or to ~/.vim/bundle/asynccommand/ for use with pathogen (vimscript #2332).
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
AsyncCommand.zip 4.0 2012-05-19 7.0 David Briscoe Fix some issues with console vim. Pass return code to handlers. Capture all output from commands. Add more error checking.
Thanks to patch contributors v.yurin and Dan Wanek.
asynccommand.zip 3.1 2011-07-11 7.0 David Briscoe Re-add AsyncMake command
asynccommand.zip 3.0 2011-06-17 7.0 David Briscoe Now a zip file.

Convert to an autoload script, add help file (big thanks to Peter Rincker!)
There are also now more predefined handlers to simplify writing your own AsyncCommands.

Fix tcsh shellredir bug (thanks to Chad Moore!)
asynccommand.vim 2.2 2011-04-05 7.0 David Briscoe Fix terminal vim problem. Add error handling for when v:servername is not set. (Thanks to dfroger!)
asynccommand.vim 2.1 2011-02-27 7.0 David Briscoe Missing braces on linux version of Async_Impl. Braces are required to make command asynchronous.
Add error checking for AsyncGrep.
asynccommand.vim 2.0 2011-02-23 7.0 David Briscoe Add AsyncMake to run make asynchronously and open results in an error window.
asynccommand.vim 1.0 2011-01-30 7.0 David Briscoe Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github