How to efficiently “make” with Vim

后端 未结 6 415
栀梦
栀梦 2020-12-06 05:07

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
`-- s         


        
6条回答
  •  广开言路
    2020-12-06 05:34

    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  -C $mkpath | cwindow 10
    

提交回复
热议问题