mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 00:00: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:pr_kind = g:spacevim_gitcommit_pr_icon
|
||||||
let s:issue_kind = g:spacevim_gitcommit_issue_icon
|
let s:issue_kind = g:spacevim_gitcommit_issue_icon
|
||||||
|
let s:cache = {}
|
||||||
|
|
||||||
function! SpaceVim#plugins#gitcommit#complete(findstart, base) abort
|
function! SpaceVim#plugins#gitcommit#complete(findstart, base) abort
|
||||||
if a:findstart
|
if a:findstart
|
||||||
|
let s:complete_ol = 0
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let start = col('.') - 1
|
let start = col('.') - 1
|
||||||
while start > 0 && line[start - 1] != ' '
|
while start > 0 && line[start - 1] != ' ' && line[start - 1] != '#'
|
||||||
let start -= 1
|
let start -= 1
|
||||||
endwhile
|
endwhile
|
||||||
return start
|
if line[start - 1] == '#'
|
||||||
|
let s:complete_ol = 1
|
||||||
|
return start + 1
|
||||||
|
else
|
||||||
|
return start
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
if a:base =~ '^#\d*'
|
if s:complete_ol == 1
|
||||||
return s:complete_pr()
|
return s:complete_pr(a:base)
|
||||||
endif
|
endif
|
||||||
let res = []
|
let res = []
|
||||||
for m in s:cache_commits()
|
for m in s:cache_commits()
|
||||||
@ -28,18 +35,25 @@ function! s:cache_commits() abort
|
|||||||
return rst
|
return rst
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:complete_pr() abort
|
function! s:complete_pr(base) abort
|
||||||
let [user,repo] = s:current_repo()
|
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 = []
|
let rst = []
|
||||||
for pr in prs
|
for pr in prs
|
||||||
let item = {
|
let item = {
|
||||||
\ 'word' : '#' . pr.number,
|
\ 'word' : pr.number . '',
|
||||||
\ 'abbr' : '#' . pr.number,
|
\ 'abbr' : '#' . pr.number,
|
||||||
\ 'menu' : pr.title,
|
\ 'menu' : pr.title,
|
||||||
\ 'kind' : (has_key(pr, 'pull_request') ? s:pr_kind : s:issue_kind),
|
\ '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
|
endfor
|
||||||
return rst
|
return rst
|
||||||
endfunction
|
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', 'mark', '')
|
||||||
"call deoplete#custom#set('phpcd', 'input_pattern', '\w*|[^. \t]->\w*|\w*::\w*')
|
"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
|
" lua
|
||||||
let g:deoplete#omni_patterns.lua = get(g:deoplete#omni_patterns, 'lua', '.')
|
let g:deoplete#omni_patterns.lua = get(g:deoplete#omni_patterns, 'lua', '.')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user