Add project collaborator username completion

Closes #1.
This commit is contained in:
Bruno Sutic
2014-07-06 00:14:04 +02:00
committed by Tim Pope
parent aa3f3e1f59
commit 9a2dff2c6c
2 changed files with 8 additions and 4 deletions

View File

@@ -3,8 +3,8 @@
Author: Tim Pope <http://tpo.pe/> Author: Tim Pope <http://tpo.pe/>
License: Same terms as Vim itself (see |license|) License: Same terms as Vim itself (see |license|)
Use |i_CTRL-X_CTRL-O| to omni-complete GitHub issues when editing a commit Use |i_CTRL-X_CTRL-O| to omni-complete GitHub issues or project collaborator
message. usernames when editing a commit message.
ABOUT *rhubarb-about* ABOUT *rhubarb-about*

View File

@@ -146,11 +146,15 @@ endfunction
function! rhubarb#omnifunc(findstart,base) function! rhubarb#omnifunc(findstart,base)
if a:findstart if a:findstart
let existing = matchstr(getline('.')[0:col('.')-1],'#\d*$') let existing = matchstr(getline('.')[0:col('.')-1],'#\d*$\|@[[:alnum:]-]*$')
return col('.')-1-strlen(existing) return col('.')-1-strlen(existing)
endif endif
try try
return map(rhubarb#repo_request('issues'), '{"word": "#".v:val.number, "menu": v:val.title, "info": substitute(v:val.body,"\\r","","g")}') if a:base =~# '^@'
return map(rhubarb#repo_request('collaborators'), '"@".v:val.login')
else
return map(rhubarb#repo_request('issues'), '{"word": "#".v:val.number, "menu": v:val.title, "info": substitute(v:val.body,"\\r","","g")}')
endif
catch /^\%(fugitive\|rhubarb\):/ catch /^\%(fugitive\|rhubarb\):/
return v:errmsg return v:errmsg
endtry endtry