mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 23:50:04 +08:00
Improve gitcommit completion
This commit is contained in:
parent
d039f06043
commit
6ef5d90a5d
@ -1,17 +1,24 @@
|
||||
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
|
||||
return start
|
||||
if line[start - 1] == '#'
|
||||
let s:complete_ol = 1
|
||||
return start + 1
|
||||
else
|
||||
return start
|
||||
endif
|
||||
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 +35,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
|
||||
|
@ -51,6 +51,11 @@ 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', [
|
||||
\'[ ]#.*',
|
||||
\])
|
||||
|
||||
" lua
|
||||
let g:deoplete#omni_patterns.lua = get(g:deoplete#omni_patterns, 'lua', '.')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user