How to efficiently "make" with Vim

makefile, plugins, vim

Solution

The solution of rampion is a first step, but computed on vim load. When I load a multi tab session, the path can be inconsistent from one tab to another.

Here my solution (+ extra with tabnew).

fun! SetMkfile()
  let filemk = "Makefile"
  let pathmk = "./"
  let depth = 1
  while depth < 4
    if filereadable(pathmk . filemk)
      return pathmk
    endif
    let depth += 1
    let pathmk = "../" . pathmk
  endwhile
  return "."
endf

command! -nargs=* Make tabnew | let $mkpath = SetMkfile() | make <args> -C $mkpath | cwindow 10

Problem

What I am trying to do seems a very basic stuff, but I can't find anything about it. I am working on a project built as usual: ``` project |-- bin |-- inc `-- src ``` I would like to make my project using the make command included in Vim. But each time I have to specify `:make -C ../`. I would prefer, if there is not Makefile file in the current directory, go in the parent directory. I already do that with ``` set tags+=./tags;/ ``` in my `.vimrc`. Furthermore, the make is by default ugly. Are there options to add color to make, and allow a direct access to the errors (as in Emacs). Thanks

Original source