Skip to content
Linwei edited this page Nov 13, 2017 · 31 revisions

Can asyncrun.vim trigger an autocommand QuickFixCmdPost to get some plugin (like errormaker) processing the content in quickfix ?

Sure you can use either g:asyncrun_exit or -post or g:asyncrun_auto in your case without modifing any code in asyncrun.vim.

setup global callback on job finished:

let g:asyncrun_exit = "silent doautocmd QuickFixCmdPost make"

setup local callback on each command:

:AsyncRun -post=silent\ doautocmd\ QuickFixCmdPost\ make @ make

There is a new option in the latest asyncrun (1.3.5) to enable asyncrun trigger QuickFixCmdPre/QuickFixCmdPost

:let g:asyncrun_auto = "make"

After that, asyncrun can cooperate with errormaker now.

Macro '%' is expanded incorrectly on windows if the filename contains spaces ?

The '%' is expanded and escaped by vim itself on the command line, and if the buffer is named 'hello world', % will be escaped as 'hello\ world' by vim. The backslash here is the escaping character, and is okay on all the unix systems, but unfortunately, on windows cmd.exe assumes it as a path seperator.

Here is another accurate form on both windows and unix:

:AsyncRun gcc "$(VIM_FILEPATH)" -o "$(VIM_FILEDIR)/$(VIM_FILENAME)"

Macros wrapped by $(...) are expanded by asyncrun with a string replacing.

Since when we have the $(...) macros, why there are still some '%...' macros ?

Any string starting with a '%', '<' or '#' in vim's command line will be expanded and escaped by vim (see: ":help filename-modifiers"). Only "$(...)" are handled by asyncrun.

$(VIM_FILEPATH) is more accurate than %:p on both windows and unix when there are spaces in the filename.

But most of time, there is no space in a filename and a lot of people don't use windows in their everyday work.

In this circumstance, you can use "%..." for short.

Output in quickfix is not matched by the local value of errorformat but the global value of it ?

Because asyncrun uses caddexpr to populate the quickfix list. And caddexpr only works with global value of the errorformat. There is an option named g:asyncrun_local which can be set to non-zero to get asyncrun to temporarily modify &g:errorformat to &l:errorformat.

Consider to the performance problems (especially for some crazy stl error outputs), g:asyncrun_local is set to zero by default. You can turn it on if you are using local errorformat. See issue 16.

Automate opening quickfix window

Use autocmd AsyncRunStart with asyncrun#quickfix_toggle in your vimrc:

augroup MyGroup
    autocmd User AsyncRunStart call asyncrun#quickfix_toggle(8, 1)
augroup END

Can't capture command's output in quickfix window ?

Has your errorformat been modified by some plugins like vim-go or polyglot ? These plugins will set errorformat to filter out non-error messages in quickfix.

see: https://github.com/skywind3000/asyncrun.vim/issues/30

see best practice of quickfix