aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-05-10 20:55:24 +0200
committerTeddy Wing2017-05-10 20:55:24 +0200
commit66b4ed72d3bc3a6c03049aa5364f567aab5ae980 (patch)
treec1fa9384c085e70ee60e691a2aa48ac3d1faa998
parent60bc8ea8b3b7be511c4240ca1d7dc1cc1149b113 (diff)
downloadvim-gitcha-66b4ed72d3bc3a6c03049aa5364f567aab5ae980.tar.bz2
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 `<C-x><C-u>`. Our map now directly invokes `gitcha#GitSHAComplete()`.
-rw-r--r--autoload/gitcha.vim33
1 files 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 "\<C-x>\<C-u>"
-endfunction