diff --git a/autoload/SpaceVim/plugins/gitcommit.vim b/autoload/SpaceVim/plugins/gitcommit.vim index 34c3a01c1..981dd2ee5 100644 --- a/autoload/SpaceVim/plugins/gitcommit.vim +++ b/autoload/SpaceVim/plugins/gitcommit.vim @@ -1,17 +1,22 @@ let s:pr_kind = g:spacevim_gitcommit_pr_icon let s:issue_kind = g:spacevim_gitcommit_issue_icon +let s: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] != ' ' + while start > 0 && line[start - 1] != ' ' && line[start - 1] != '#' let start -= 1 endwhile + if line[start - 1] == '#' + let s:complete_ol = 1 + endif return start else - if a:base =~ '^#\d*' - return s:complete_pr() + if s:complete_ol == 1 + return s:complete_pr(a:base) endif let res = [] for m in s:cache_commits() @@ -28,18 +33,25 @@ function! s:cache_commits() abort return rst endfunction -function! s:complete_pr() abort +function! s:complete_pr(base) abort let [user,repo] = s:current_repo() - let prs = github#api#issues#List_All_for_Repo(user, repo) + if !has_key(s:cache, user . '_' . repo) + let prs = github#api#issues#List_All_for_Repo(user, repo) + let s:cache[user . '_' . repo] = prs + else + let prs = s:cache[user . '_' . repo] + endif let rst = [] for pr in prs let item = { - \ 'word' : '#' . pr.number, + \ 'word' : pr.number . '', \ 'abbr' : '#' . pr.number, \ 'menu' : pr.title, \ 'kind' : (has_key(pr, 'pull_request') ? s:pr_kind : s:issue_kind), \ } - call add(rst, item) + if pr.number . pr.title =~? a:base + call add(rst, item) + endif endfor return rst endfunction diff --git a/config/plugins/deoplete.vim b/config/plugins/deoplete.vim index e5e2965bd..25e6e70cd 100644 --- a/config/plugins/deoplete.vim +++ b/config/plugins/deoplete.vim @@ -51,6 +51,13 @@ let g:deoplete#ignore_sources.php = get(g:deoplete#ignore_sources, 'php', ['phpc "call deoplete#custom#set('phpcd', 'mark', '') "call deoplete#custom#set('phpcd', 'input_pattern', '\w*|[^. \t]->\w*|\w*::\w*') +" gitcommit +let g:deoplete#omni#input_patterns.gitcommit = get(g:deoplete#omni#input_patterns, 'gitcommit', [ + \'[ ]#[ 0-9a-zA-Z]*', + \]) + +let g:deoplete#ignore_sources.gitcommit = ['neosnippet'] + " lua let g:deoplete#omni_patterns.lua = get(g:deoplete#omni_patterns, 'lua', '.')