mirror of
https://github.com/tpope/vim-rhubarb.git
synced 2025-12-06 12:14:26 +08:00
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
45 lines
1.4 KiB
VimL
45 lines
1.4 KiB
VimL
" rhubarb.vim - fugitive.vim extension for GitHub
|
|
" Maintainer: Tim Pope <http://tpo.pe/>
|
|
|
|
if exists("g:loaded_rhubarb") || v:version < 700 || &cp
|
|
finish
|
|
endif
|
|
let g:loaded_rhubarb = 1
|
|
|
|
if !exists('g:dispatch_compilers')
|
|
let 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(s:config()),
|
|
\ '!empty(rhubarb#homepage_for_url(matchstr(v:val, ''^\s*url\s*=\s*"\=\zs\S*'')))')) |
|
|
\ setlocal omnifunc=rhubarb#omnifunc |
|
|
\ endif
|
|
autocmd BufEnter *
|
|
\ if expand('%') ==# '' && &previewwindow && pumvisible() && getbufvar('#', '&omnifunc') ==# 'rhubarb#omnifunc' |
|
|
\ setlocal nolist linebreak filetype=markdown |
|
|
\ endif
|
|
augroup END
|
|
|
|
if !exists('g:fugitive_browse_handlers')
|
|
let g:fugitive_browse_handlers = []
|
|
endif
|
|
|
|
if index(g:fugitive_browse_handlers, function('rhubarb#fugitive_url')) < 0
|
|
call insert(g:fugitive_browse_handlers, function('rhubarb#fugitive_url'))
|
|
endif
|