vim和项目make的绑定

时间:2022-09-02 04:43:39

make在vim中的使用和grep类似,:help make里面给了更多的细节。
下面主要是vim应用在apollo项目编译时的一些脚本。使得可以在vim中编译apollo模块,以及跳到编译出错的地方。

"------------------------------ Make commands --------------------------
let g:makedict = {'all': "make -C $build/systems/linux/skyworth"}
let g:makedict['kernel']="echo \"-C kernel\""
fu! MakeExecute(command)
    let space=stridx(a:command, " ")
    let param1=strpart(a:command, 0, space)
    let params=strpart(a:command, space+1)

    let cmd="echo \"error key value \""
    if strlen(param1) == 0
        if strlen(params) == 0
          let cmd=g:makedict['all']
          let param=""
        else
          if has_key(g:makedict, params)
              let cmd=g:makedict[params]
          endif
          let param=""
        endif
    else
        if has_key(g:makedict, param1)
            let cmd=g:makedict[param1]
        endif
        let param=params
    endif
    execute cmd . " " . param

endf

com! -nargs=* Make call MakeExecute("<args>")