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
Another approach can be used if you have a single makefile on project root directory:
project
|-- bin
|-- inc
|-- src
| Makefile
With your project path in variable like b:projectDir
it is possible to use an "autocommand" to change to that directory before start executing :make
or :lmake
:
augroup changeMakeDir
au!
autocmd QuickfixCmdPre *make
\ if exists("b:projectDir") &&
\ b:projectDir != expand("%:p:h") |
\ exe 'cd ' . b:projectDir |
\ endif
augroup END
Projectroot plugin can be used to set b:projectDir
; it also provides the commands to change the current directory to the project root directory:
augroup changeMakeDir
au!
autocmd QuickfixCmdPre make ProjectRootCD
augroup END