diff options
author | Teddy Wing | 2017-04-27 23:38:42 +0200 |
---|---|---|
committer | Teddy Wing | 2017-04-27 23:38:42 +0200 |
commit | 586fb4aa1743f69e6e388f5625d5f9dd9a297a25 (patch) | |
tree | 79be2c9632b54a1f9afcf66f1ba1a540c8a119c3 | |
download | vim-gitcha-586fb4aa1743f69e6e388f5625d5f9dd9a297a25.tar.bz2 |
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.
-rw-r--r-- | ftplugin/gitcommit.vim | 21 |
1 files changed, 21 insertions, 0 deletions
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 |