mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-11 08:55:43 +08:00
parent
1e5ba2553d
commit
ca0ef50614
@ -1,22 +1,29 @@
|
||||
"=============================================================================
|
||||
" gitcommit.vim --- omni plugin for git commit
|
||||
" Copyright (c) 2016-2017 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg at 163.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
|
||||
let s:pr_kind = g:spacevim_gitcommit_pr_icon
|
||||
let s:issue_kind = g:spacevim_gitcommit_issue_icon
|
||||
let s:cache = {}
|
||||
let s:pr_cache = {}
|
||||
" pr_cache
|
||||
" {
|
||||
" 'user - repo' : { pr.number : pr}
|
||||
" }
|
||||
|
||||
" TODO: add asycn support
|
||||
let s:github_cache = {}
|
||||
|
||||
|
||||
function! SpaceVim#plugins#gitcommit#complete(findstart, base) abort
|
||||
if a:findstart
|
||||
let s:complete_ol = 0
|
||||
let line = getline('.')
|
||||
let start = col('.') - 1
|
||||
while start > 0 && line[start - 1] != ' ' && line[start - 1] != '#'
|
||||
while start > 0 && line[start - 1] !=# ' ' && line[start - 1] !=# '#'
|
||||
let start -= 1
|
||||
endwhile
|
||||
if line[start - 1] == '#'
|
||||
if line[start - 1] ==# '#'
|
||||
let s:complete_ol = 1
|
||||
endif
|
||||
return start
|
||||
@ -41,12 +48,14 @@ endfunction
|
||||
|
||||
function! s:complete_pr(base) abort
|
||||
let [user,repo] = s:current_repo()
|
||||
if !has_key(s:cache, user . '_' . repo)
|
||||
let s:user = user
|
||||
let s:repo = repo
|
||||
if !has_key(s:pr_cache, user . '_' . repo)
|
||||
call s:cache_prs(user, repo)
|
||||
endif
|
||||
let prs = get(s:cache, user . '_' . repo, [])
|
||||
let prs = get(s:pr_cache, user . '_' . repo, {})
|
||||
let rst = []
|
||||
for pr in prs
|
||||
for pr in values(prs)
|
||||
let item = {
|
||||
\ 'word' : pr.number . '',
|
||||
\ 'abbr' : '#' . pr.number,
|
||||
@ -93,7 +102,11 @@ function! s:cache_prs(user, repo) abort
|
||||
if !has_key(s:pr_cache, a:user . '_' . a:repo)
|
||||
call extend(s:pr_cache, {a:user . '_' . a:repo : {}})
|
||||
endif
|
||||
call github#api#issue#list_all_for_repo(a:user, a:repo, function('s:list_callback'))
|
||||
call github#api#issues#async_list_opened(a:user, a:repo, function('s:callback'))
|
||||
endfunction
|
||||
|
||||
function! s:callback(data) abort
|
||||
call s:list_callback(s:user, s:repo, a:data)
|
||||
endfunction
|
||||
|
||||
" data is a list a PRs in one page
|
||||
|
Loading…
x
Reference in New Issue
Block a user