diff options
| author | Teddy Wing | 2017-04-28 01:14:39 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-04-28 01:14:39 +0200 | 
| commit | 08dd78c72a5935fd1aa458c28c2b045a2e4aab39 (patch) | |
| tree | 0d9f2b36ebe8ec176f95ff747bb3f39c1f0aeac3 /ftplugin | |
| parent | 41b7976991b46915ad5cd6b8a25aa92ea5334db0 (diff) | |
| download | vim-gitcha-08dd78c72a5935fd1aa458c28c2b045a2e4aab39.tar.bz2 | |
ftplugin/gitcommit.vim: Restore user completion function
Make our custom mapping work while retaining any user-defined
`completefunc`.
Doing it this way enables us to get away without having to set a hacky
`CursorMovedI` unsetting autocommand as imagined in
e70d92c495001c0af0037b9fadbeec170d2c318f.
We clutter our `GitSHAComplete` completion function a bit with
functionality that doesn't really belong to it in order to get a win for
simple implementation of the `completefunc` restore feature.
Diffstat (limited to 'ftplugin')
| -rw-r--r-- | ftplugin/gitcommit.vim | 9 | 
1 files changed, 5 insertions, 4 deletions
diff --git a/ftplugin/gitcommit.vim b/ftplugin/gitcommit.vim index 485a7c1..e08f2e0 100644 --- a/ftplugin/gitcommit.vim +++ b/ftplugin/gitcommit.vim @@ -1,3 +1,5 @@ +let s:old_completefunc = &completefunc +  function! GitSHAComplete(findstart, base)  	if a:findstart  		" locate the start of the word @@ -9,6 +11,9 @@ function! GitSHAComplete(findstart, base)  		return start  	endif +	" Restore user completion function +	let &completefunc = s:old_completefunc +  	" Match Git SHAs in the current repository  	let matches = []  	let revs = system('git rev-list --all') @@ -22,12 +27,8 @@ function! GitSHAComplete(findstart, base)  endfunction  function! StartGitSHACompletion() -	let old_completefunc = &completefunc -  	set completefunc=GitSHAComplete  	return "\<C-x>\<C-u>" - -	let &completefunc = old_completefunc  endfunction  inoremap <expr> <C-x><C-s> StartGitSHACompletion()  | 
