diff options
author | Teddy Wing | 2017-04-27 23:58:01 +0200 |
---|---|---|
committer | Teddy Wing | 2017-04-27 23:58:01 +0200 |
commit | 62ca44d3f5ff9d339baf6a12bd46c68dccf94591 (patch) | |
tree | 3a755dc00b8e25b1ba2787d45e3b2b5bf6da7e7b | |
parent | 586fb4aa1743f69e6e388f5625d5f9dd9a297a25 (diff) | |
download | vim-gitcha-62ca44d3f5ff9d339baf6a12bd46c68dccf94591.tar.bz2 |
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.
-rw-r--r-- | ftplugin/gitcommit.vim | 19 |
1 files 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 |