You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to search current word under cursor, you can use <c-r><c-w> to pick up current word, or define another task to search word under cursor directly:
Be aware, commands starting with a colon (command:vim=:source %) will be executed as vimscript.
Internal Variable Example
asynctasks.vim allows command have internal variables in $(VIM:varname) form:
[test-var-replace]command=echo $(VIM:my_name)
And in your vimrc, you can define a dictionary contains this internal variables:
letg:asynctasks_environ= {'my_name': 'Somebody'}
And command :AsyncTask test-var-replace will output:
Somebody
WSL Example
If you are working in Windows GVim like me, you may want to edit with GVim.exe but compile and run your file in WSL. asynctasks.vim enables you to achieve this by simply including a program=wsl in your task configuration:
Macros starting with VIM_ can still be used, in addition, there are some special macros for wsl:
$(WSL_FILEPATH)# (WSL) File name of current buffer with full path$(WSL_FILENAME)# (WSL) File name of current buffer without path$(WSL_FILEDIR)# (WSL) Full path of current buffer without the file name$(WSL_FILENOEXT)# (WSL) File name of current buffer without path and extension$(WSL_PATHNOEXT)# (WSL) Current file name with full path but without extension$(WSL_RELDIR)# (WSL) File path relativize to current directory$(WSL_RELNAME)# (WSL) File name relativize to current directory$(WSL_ROOT)# (WSL) Project root directory$(WSL_CWD)# (WSL) Current directory$(WSL_CFILE)# (WSL) Current filename under cursor
for example, current $(VIM_FILEPATH) is:
D:\Source\Project1\src\hello.c
It will be converted in $(WSL_FILEPATH) as:
/mnt/d/Source/Project1/src/hello.c
You can use :AsyncTaskMacro! to check them out in Windows.
MSYS and Cygwin
When program is one of msys, mingw32 and mingw64, the task will use msys.
The only thing required it to tell asyncrun where your msys/git-bash is:
# use a standalone MSYS2
letg:asyncrun_msys='D:\MSYS32'
# or use git-bash
letg:asyncrun_msys='C:\Program Files\Git'
When program is cygwin, it will locate cygwin folder in g:asyncrun_cygwin, and tasks for cygwin can use macros starting with CYGWIN_, eg. $(CYGWIN_FILENAME).
Range Example
try this:
[cat-me]command=cat
use it as:
:%AsyncTask cat-me
The whole buffer will be sen5 to cat command from stdin. You can specify a line range like:
:10,20AsyncTask cat-me
The content between line 10 to 20 will be sent to cat from its stdin. Visual selection also works.
Beware: this feature is only available when output=quickfix
Silence and Notify
If there is a silent=1 in your task, quickfix window will not open automatically no matter g:asyncrun_open is set or not:
echo: echo a status in the cmdline when task finished.
bell: ring a bell when task finished.
sound:xxx.wav: play a sound when task finished.
:script: execute a vim script when task finished.
For vim built with +sound feature, you can define a sound:xxx like:
# play sound when finishednotify=sound:~/documents/finish.wav
# play success.wav if return code is zero, otherwise play failure.wavnotify=sound:~/documents/success.wav,~/documents/failure.wav
# call a function when finishednotify=:call MyTaskFinish()