mirror of
https://github.com/tpope/vim-rhubarb.git
synced 2025-12-07 12:44:27 +08:00
Extract commit message setup function
This commit is contained in:
@@ -11,25 +11,25 @@ if !exists('g:dispatch_compilers')
|
|||||||
endif
|
endif
|
||||||
let g:dispatch_compilers['hub'] = 'git'
|
let g:dispatch_compilers['hub'] = 'git'
|
||||||
|
|
||||||
function! s:Config() abort
|
function! s:SetUpMessage(filename) abort
|
||||||
if exists('*FugitiveFind')
|
if &omnifunc !~# '^\%(syntaxcomplete#Complete\)\=$' ||
|
||||||
let dir = FugitiveFind('.git/config')[0:-8]
|
\ a:filename !~# '\.git[\/].*MSG$' ||
|
||||||
return filereadable(dir . '/config') ? readfile(dir . '/config') : []
|
\ !exists('*FugitiveFind') || empty(FugitiveGitDir())
|
||||||
else
|
return
|
||||||
return []
|
endif
|
||||||
|
let config_file = FugitiveFind('.git/config')
|
||||||
|
let config = filereadable(config_file) ? readfile(config_file) : []
|
||||||
|
if !empty(filter(config,
|
||||||
|
\ '!empty(rhubarb#HomepageForUrl(matchstr(v:val, ''^\s*url\s*=\s*"\=\zs\S*'')))'))
|
||||||
|
setlocal omnifunc=rhubarb#Complete
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
augroup rhubarb
|
augroup rhubarb
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd User Fugitive
|
if exists('+omnifunc')
|
||||||
\ if expand('%:p') =~# '\.git[\/].*MSG$' &&
|
autocmd User Fugitive call s:SetUpMessage(expand('%:p'))
|
||||||
\ exists('+omnifunc') &&
|
endif
|
||||||
\ &omnifunc =~# '^\%(syntaxcomplete#Complete\)\=$' &&
|
|
||||||
\ !empty(filter(s:Config(),
|
|
||||||
\ '!empty(rhubarb#HomepageForUrl(matchstr(v:val, ''^\s*url\s*=\s*"\=\zs\S*'')))')) |
|
|
||||||
\ setlocal omnifunc=rhubarb#Complete |
|
|
||||||
\ endif
|
|
||||||
autocmd BufEnter *
|
autocmd BufEnter *
|
||||||
\ if expand('%') ==# '' && &previewwindow && pumvisible() && getbufvar('#', '&omnifunc') ==# 'rhubarb#omnifunc' |
|
\ if expand('%') ==# '' && &previewwindow && pumvisible() && getbufvar('#', '&omnifunc') ==# 'rhubarb#omnifunc' |
|
||||||
\ setlocal nolist linebreak filetype=markdown |
|
\ setlocal nolist linebreak filetype=markdown |
|
||||||
|
|||||||
Reference in New Issue
Block a user