63 lines
1.5 KiB
VimL
63 lines
1.5 KiB
VimL
"
|
|
" Authors: Vahagn Khachatryan (vahagn DOT khachatryan AT gmail DOT com)
|
|
"
|
|
" Licence: http://www.opensource.org/licenses/mit-license.php
|
|
" The MIT License
|
|
"
|
|
" This file is based on Andy Dawson's independence.vim
|
|
"
|
|
"-----------------------------------------------------------------------------
|
|
"
|
|
" Section: Documentation
|
|
"
|
|
" The vim local-vimrc plugin loads a .vimrc file from upper directories if
|
|
" it exists. This allows you to override your vim settings on a directory tree
|
|
" basis.
|
|
|
|
" Section: Plugin header
|
|
"
|
|
" loaded_local_vimrc is set to 1 when initialization begins, and 2 when it
|
|
" completes.
|
|
if exists('g:loaded_locl_vimrc')
|
|
finish
|
|
endif
|
|
let g:loaded_local_vimrc=1
|
|
|
|
" Section: Event group setup
|
|
" Act when creating or loading a file
|
|
augroup LocalVimrc
|
|
au BufNewFile,BufRead * call s:LoadConfig()
|
|
augroup END
|
|
|
|
" Function: LoadConfig()
|
|
"
|
|
" If the file .vimrc exists in the root of a git project - load it
|
|
function s:LoadConfig()
|
|
let l:path = fnameescape(expand("%:p:h"))
|
|
if empty(l:path)
|
|
return
|
|
endif
|
|
|
|
let l:paths = []
|
|
let l:pathp = ""
|
|
while l:pathp != l:path
|
|
let l:vimrc = l:path.'/.vimrc.local'
|
|
if filereadable(l:vimrc) && l:vimrc != $MYVIMRC
|
|
let l:paths = [ l:vimrc ] + l:paths
|
|
endif
|
|
"echo 'try'.l:path
|
|
|
|
let l:pathp = l:path
|
|
let l:path = fnamemodify(l:path, ":h")
|
|
endwhile
|
|
|
|
"echo l:paths
|
|
for vimrc in l:paths
|
|
exec ":source " . vimrc
|
|
endfor
|
|
|
|
endfunction
|
|
|
|
" Section: Plugin completion
|
|
let g:loaded_local_vimrc=2
|