Guest User

Untitled

a guest
Sep 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1.  
  2. function! SourceGitVimrc(dir)
  3. let gitroot = system("cd " . fnameescape(a:dir) . "; git rev-parse --show-toplevel 2>/dev/null")
  4. " Strip trailing newline and escape
  5. let gitroot = substitute(gitroot, "\\n*$","","")
  6. if strlen(gitroot) && filereadable(gitroot . '/.vimrc')
  7. execute "source " . fnameescape(gitroot) . '/.vimrc'
  8. endif
  9. endfunction
  10.  
  11. autocmd BufRead * call SourceGitVimrc(expand("<afile>:p:h"))
Add Comment
Please, Sign In to add comment