From 586fb4aa1743f69e6e388f5625d5f9dd9a297a25 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 27 Apr 2017 23:38:42 +0200 Subject: Sample completion function Copy the completion function included in `:h complete-functions` to give us a base custom completion function to work from. We'll be using this to provide completion for Git SHAs. --- ftplugin/gitcommit.vim | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 ftplugin/gitcommit.vim diff --git a/ftplugin/gitcommit.vim b/ftplugin/gitcommit.vim new file mode 100644 index 0000000..592e67e --- /dev/null +++ b/ftplugin/gitcommit.vim @@ -0,0 +1,21 @@ +function! GitSHAComplete(findstart, base) + if a:findstart + " locate the start of the word + let line = getline('.') + let start = col('.') - 1 + while start > 0 && line[start - 1] =~ '\a' + let start -= 1 + endwhile + 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 +endfunction +set completefunc=GitSHAComplete -- cgit v1.2.3