mirror of
https://github.com/tpope/vim-rhubarb.git
synced 2025-12-07 04:34:27 +08:00
Make config file check more robust
This commit is contained in:
@@ -16,11 +16,16 @@ if get(g:, 'fugitive_git_command', 'git') ==# 'git' && executable('hub')
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
function! s:config() abort
|
function! s:config() abort
|
||||||
let common_dir = fugitive#buffer().repo().dir('commondir')
|
if exists('*FugitiveCommonDir')
|
||||||
if filereadable(common_dir)
|
let dir = FugitiveCommonDir()
|
||||||
return fugitive#buffer().repo().dir(readfile(common_dir)[0] . '/config')
|
else
|
||||||
|
let dir = get(b:, 'git_dir', '')
|
||||||
|
let common_dir = b:git_dir . '/commondir'
|
||||||
|
if filereadable(dir . '/commondir')
|
||||||
|
let dir .= '/' . readfile(common_dir)[0]
|
||||||
endif
|
endif
|
||||||
return fugitive#buffer().repo().dir('config')
|
endif
|
||||||
|
return filereadable(dir . '/config') ? readfile(dir . '/config') : []
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
augroup rhubarb
|
augroup rhubarb
|
||||||
@@ -29,7 +34,7 @@ augroup rhubarb
|
|||||||
\ if expand('%:p') =~# '\.git[\/].*MSG$' &&
|
\ if expand('%:p') =~# '\.git[\/].*MSG$' &&
|
||||||
\ exists('+omnifunc') &&
|
\ exists('+omnifunc') &&
|
||||||
\ &omnifunc =~# '^\%(syntaxcomplete#Complete\)\=$' &&
|
\ &omnifunc =~# '^\%(syntaxcomplete#Complete\)\=$' &&
|
||||||
\ !empty(filter(readfile(s:config()),
|
\ !empty(filter(s: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