From 62ca44d3f5ff9d339baf6a12bd46c68dccf94591 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 27 Apr 2017 23:58:01 +0200 Subject: ftplugin/gitcommit.vim: Make completion work for commit SHAs Get the list of SHAs from `git rev-list` and use this for completion. Not too different from the original structure. Renamed `res` to `matches` because that seemed clearer to me. --- ftplugin/gitcommit.vim | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ftplugin/gitcommit.vim b/ftplugin/gitcommit.vim index 592e67e..daed923 100644 --- a/ftplugin/gitcommit.vim +++ b/ftplugin/gitcommit.vim @@ -9,13 +9,16 @@ function! GitSHAComplete(findstart, base) return start endif - " find months matching with "a:base" - let res = [] - for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") - if m =~ '^' . a:base - call add(res, m) - endif - endfor - return res + " Match Git SHAs in the current repository + let matches = [] + let revs = system('git rev-list --all') + for m in split(revs) + if m =~ '^' . a:base + call add(matches, m) + endif + endfor + + return matches endfunction + set completefunc=GitSHAComplete -- cgit v1.2.3