aboutsummaryrefslogtreecommitdiffstats
path: root/ftplugin/gitcommit/gitcha.vim
diff options
context:
space:
mode:
authorTeddy Wing2017-04-29 04:48:35 +0200
committerTeddy Wing2017-04-29 04:48:35 +0200
commitee60b16343ff5e98dc4279bb976586001a002bfe (patch)
treecd8e1d232af2ea82d6424305d5566ee9cfd1323d /ftplugin/gitcommit/gitcha.vim
parentbc4fcb2b082805914d6e87ff38516dbafc5c5538 (diff)
downloadvim-gitcha-ee60b16343ff5e98dc4279bb976586001a002bfe.tar.bz2
Move functions to autoload/
Don't force our functions to be loaded when the ftplugin is loaded. Be good Vimscript citizens and respect load performance.
Diffstat (limited to 'ftplugin/gitcommit/gitcha.vim')
-rw-r--r--ftplugin/gitcommit/gitcha.vim35
1 files changed, 1 insertions, 34 deletions
diff --git a/ftplugin/gitcommit/gitcha.vim b/ftplugin/gitcommit/gitcha.vim
index e08f2e0..ecd1e90 100644
--- a/ftplugin/gitcommit/gitcha.vim
+++ b/ftplugin/gitcommit/gitcha.vim
@@ -1,34 +1 @@
-let s:old_completefunc = &completefunc
-
-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
-
- " 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')
- for m in split(revs)
- if m =~ '^' . a:base
- call add(matches, m)
- endif
- endfor
-
- return matches
-endfunction
-
-function! StartGitSHACompletion()
- set completefunc=GitSHAComplete
- return "\<C-x>\<C-u>"
-endfunction
-
-inoremap <expr> <C-x><C-s> StartGitSHACompletion()
+inoremap <expr> <C-x><C-s> gitcha#StartGitSHACompletion()