You cannot run the built-in command :make
asynchronously in Vim8 or NeoVim.
You have to take the value of 'makeprg'
and insert it into vim8 job_start()
or neovim jobstart()
.
I personally like the convenience of plugins which take care of vim8/neovim differences, parsing the result and inserting it into the quickfix/location list, ...
As often the case for vim, there are many plugins you can choose from:
I would recommend to try first vim-dispatch
by tpope. It provides
- familiar command names
:Make
, :Copen
, ...
- a convenience command
:Dispatch
to activate compiler/linter and run it in one step.
- IMHO nice default maps
`m
for :Make
and `<Space>
for :Dispatch<Space>
and more
- limited feature set
Some people like to use different plugins for following reason
- limitations of
'errorformat'
for parsing of compiler/linter results
- vim-dispatch does not open the quickfix list automatically in case of warnings and errors (issue #226) (see e.g. neomake)
- handling of several linter/static code analyzer/...
BTW good companion plugins are
vim-projectionist: e.g. helpful for out-of-source builds when using CMake (similar for meson). You can define heuristics to detect out-of-source builds. I often put the out-of source build next to <project>/CMakeLists.txt
into <project>/_builds/debug
which means I set in my vimrc:
let g:projectionist_heuristics = {
\ "CMakeLists.txt&builds/debug/Makefile": {
\ "*": {
\ "make": "make -C {project}/builds/debug -j8",
\ "compiler": "gcc",
\ }
\ }
\ }
vim-projectionist
can detect your build directory automatically and allows you to press `m
to compile in this directory.
You have to modify this to your personal preference. You can also define several heuristics.
vim-unimpaired: nice additional non-clashing maps ]q
, [q
, ]Q
, [Q
to navigate the quickfix list.
Furthermore, vim-fugitive uses :Make
if available for git push/pull
which means it runs them async as well.
You can also use other plugins for this. For example, define :Make
using neomake:
command! -bang -nargs=* -complete=file Make NeomakeProject <args>
If you have added the above line, vim-fugitive runs git push/pull without blocking the editor but uses neomake and not vim-dispatch.
:help job_start()
. NeoVim has a similar API but the function isjobstart()
instead.