mirror of
https://github.com/tpope/vim-rhubarb.git
synced 2025-12-06 12:14:26 +08:00
Support completion of issue URL
You can still complete the issue number only by typing a "#" beforehand.
This commit is contained in:
@@ -32,16 +32,21 @@ function! s:shellesc(arg) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:repo_name() abort
|
function! s:repo_homepage() abort
|
||||||
if !exists('b:github_repo')
|
if !exists('b:rhubarb_homepage')
|
||||||
let repo = fugitive#buffer().repo()
|
let repo = fugitive#buffer().repo()
|
||||||
let url = repo.config('remote.origin.url')
|
let url = repo.config('remote.origin.url')
|
||||||
if url !~# 'github\.com[:/][^/]*/[^/]*\.git'
|
let name = matchstr(url, 'github\.com[:/]\zs[^/]*/[^/]\{-\}\ze\%(\.git\)\=$')
|
||||||
|
if empty(name)
|
||||||
call s:throw('origin is not a GitHub repository: '.url)
|
call s:throw('origin is not a GitHub repository: '.url)
|
||||||
endif
|
endif
|
||||||
let b:github_repo = matchstr(url,'github\.com[:/]\zs[^/]*/[^/]*\ze\.git')
|
let b:rhubarb_homepage = 'https://github.com/'.name
|
||||||
endif
|
endif
|
||||||
return b:github_repo
|
return b:rhubarb_homepage
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:repo_name() abort
|
||||||
|
return matchstr(s:repo_homepage(), '://[^/]*/\zs.*')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
@@ -153,7 +158,8 @@ function! rhubarb#omnifunc(findstart,base) abort
|
|||||||
if a:base =~# '^@'
|
if a:base =~# '^@'
|
||||||
return map(rhubarb#repo_request('collaborators'), '"@".v:val.login')
|
return map(rhubarb#repo_request('collaborators'), '"@".v:val.login')
|
||||||
else
|
else
|
||||||
return map(rhubarb#repo_request('issues'), '{"word": "#".v:val.number, "menu": v:val.title, "info": substitute(v:val.body,"\\r","","g")}')
|
let prefix = (a:base =~# '^#' ? '#' : s:repo_homepage().'/issues/')
|
||||||
|
return map(rhubarb#repo_request('issues'), '{"word": prefix.v:val.number, "menu": v:val.title, "info": substitute(v:val.body,"\\r","","g")}')
|
||||||
endif
|
endif
|
||||||
catch /^\%(fugitive\|rhubarb\):/
|
catch /^\%(fugitive\|rhubarb\):/
|
||||||
return v:errmsg
|
return v:errmsg
|
||||||
|
|||||||
Reference in New Issue
Block a user