8 years ago
This script will search for
../../.project.vim etc until it finds one. If it finds one, it will source it.
This hasn't been modified to work on Windows, but shouldn't be hard to modify. Also I'm sure there are optimizations that could be made here, but it hasn't slowed me down at all.
function! s:findFileBackward(path, filename) let file = a:filename let path = a:path if !strlen(path) let path = '.' endif while !filereadable(file) if path ==# '/' return '' endif let path = system('cd '.shellescape(path.'/..').' && echo -n $PWD') let file = path.'/'.a:filename endwhile return file endfunction function! FindFileBackward(filename) " Try to resolve the file from the current buffer first let file = s:findFileBackward(expand('%:h'), a:filename) if !strlen(file) " Try to resolve the file from the cwd return s:findFileBackward(getcwd(), a:filename) endif return file endfunction let g:project_local_vimrc = FindFileBackward('.project.vim') if filereadable(g:project_local_vimrc) execute 'source ' . g:project_local_vimrc endif