mirror of
https://github.com/tpope/vim-rhubarb.git
synced 2025-12-07 20:54:27 +08:00
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:
@@ -11,14 +11,21 @@ if !exists('g:dispatch_compilers')
|
|||||||
endif
|
endif
|
||||||
let g:dispatch_compilers['hub'] = 'git'
|
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
|
augroup rhubarb
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd User Fugitive
|
autocmd User Fugitive
|
||||||
\ if expand('%:p') =~# '\.git[\/].*MSG$' &&
|
\ if expand('%:p') =~# '\.git[\/].*MSG$' &&
|
||||||
\ exists('+omnifunc') &&
|
\ exists('+omnifunc') &&
|
||||||
\ &omnifunc =~# '^\%(syntaxcomplete#Complete\)\=$' &&
|
\ &omnifunc =~# '^\%(syntaxcomplete#Complete\)\=$' &&
|
||||||
\ !empty(filter(
|
\ !empty(filter(readfile(s:config()),
|
||||||
\ readfile(fugitive#buffer().repo().dir('config')),
|
|
||||||
\ '!empty(rhubarb#homepage_for_url(matchstr(v:val, ''^\s*url\s*=\s*"\=\zs\S*'')))')) |
|
\ '!empty(rhubarb#homepage_for_url(matchstr(v:val, ''^\s*url\s*=\s*"\=\zs\S*'')))')) |
|
||||||
\ setlocal omnifunc=rhubarb#omnifunc |
|
\ setlocal omnifunc=rhubarb#omnifunc |
|
||||||
\ endif
|
\ endif
|
||||||
|
|||||||
Reference in New Issue
Block a user