From 66b4ed72d3bc3a6c03049aa5364f567aab5ae980 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 10 May 2017 20:55:24 +0200 Subject: autoload/gitcha.vim: Remove cruft after switching to `complete()` Remove all the cruft from 60bc8ea8b3b7be511c4240ca1d7dc1cc1149b113: * Don't store user-defined 'completefunc' any more since we no longer change that setting. * Remove the commented `a:findstart` code, which is no longer relevant since this function is no longer a 'completefunc'. * Remove commented test & debugging code * Remove the `gitcha#StartGitSHACompletion()` function, which was there only to facilitate mapping to the user completion function defined in 'completefunc' using the Vim-assigned mapping ``. Our map now directly invokes `gitcha#GitSHAComplete()`. --- autoload/gitcha.vim | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/autoload/gitcha.vim b/autoload/gitcha.vim index c2e30b1..13d61bf 100644 --- a/autoload/gitcha.vim +++ b/autoload/gitcha.vim @@ -1,19 +1,14 @@ -" Save user-defined completefunc so it can be restored after running this +" Save user-defined 'completeopt's so they can be restored after running this " custom completion function -let s:old_completefunc = &completefunc let s:old_completeopt = &completeopt " Completion for Git SHAs in the current repository function! gitcha#GitSHAComplete() - " if a:findstart - " locate the start of the word - let line = getline('.') - let start = col('.') - while start > 0 && line[start - 2] =~ '[0-9a-f]' - let start -= 1 - endwhile - " return start - " endif + let line = getline('.') + let start = col('.') + while start > 0 && line[start - 2] =~ '[0-9a-f]' + let start -= 1 + endwhile " Match Git SHAs in the current repository let matches = [] @@ -26,13 +21,12 @@ function! gitcha#GitSHAComplete() endif endfor - " echom start - " echom string(matches) - " let &completeopt = 'menu,pattern,menuone' set completeopt=menu,menuone,preview + call complete(start, matches) - " call complete(col('.'), matches) + let &completeopt = s:old_completeopt + return '' endfunction @@ -59,12 +53,3 @@ function! s:BuildMatchDictionary(rev_list) return matches endfunction - -" Allow mappings to initiate completion -function! gitcha#StartGitSHACompletion() - " call gitcha#GitSHAComplete() - " return '' - " set completefunc=gitcha#GitSHAComplete - " set completeopt=menu,menuone,preview - " return "\\" -endfunction -- cgit v1.2.3