Find proper config when running in worktree (#14)

Check if in worktree (by checking for a 'commondir' file) and using that
to find the parent config.  Otherwise just use the config in .git.

closes #13
This commit is contained in:
Nate Jones
2016-06-17 12:19:42 -07:00
committed by Tim Pope
parent 8620dc1277
commit 0c12c7ed7c

View File

@@ -11,14 +11,21 @@ if !exists('g:dispatch_compilers')
endif
let g:dispatch_compilers['hub'] = 'git'
function! s:config() abort
let common_dir = fugitive#buffer().repo().dir('commondir')
if filereadable(common_dir)
return fugitive#buffer().repo().dir(readfile(common_dir)[0] . '/config')
endif
return fugitive#buffer().repo().dir('config')
endfunction
augroup rhubarb
autocmd!
autocmd User Fugitive
\ if expand('%:p') =~# '\.git[\/].*MSG$' &&
\ exists('+omnifunc') &&
\ &omnifunc =~# '^\%(syntaxcomplete#Complete\)\=$' &&
\ !empty(filter(
\ readfile(fugitive#buffer().repo().dir('config')),
\ !empty(filter(readfile(s:config()),
\ '!empty(rhubarb#homepage_for_url(matchstr(v:val, ''^\s*url\s*=\s*"\=\zs\S*'')))')) |
\ setlocal omnifunc=rhubarb#omnifunc |
\ endif