aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-05-10 00:24:43 +0200
committerTeddy Wing2017-05-10 00:24:43 +0200
commite7fb8f326e7c3e184e305286199640fdaac35d5b (patch)
tree8b140bdb09339a8fdbbd1ffbe8fcfbda2c57405c
parent5eca0d8f26acf29edbcc2376f6a8cd7a9d928a2f (diff)
downloadvim-gitcha-e7fb8f326e7c3e184e305286199640fdaac35d5b.tar.bz2
autoload/gitcha.vim: Set completeopt+=menuone
Work in progress Adds 'menuone' to the 'completeopt' option. This makes the popup menu display even if there's only a single result. We want this because it allows us to see the commit message subject for the completed SHA, providing a way to confirm that the completed SHA is the right one. Here, the idea was to try to save the user's 'completeopt' setting and restore it after completion, but we can't do that in `gitcha#GitSHAComplete` because if we do, it restores 'completeopt' before the completion menu is shown. Thus, it cancels out our custom `+=menuone` setting. After checking online to see how other plugins handle this (https://github.com/search?utf8=%E2%9C%93&q=completeopt+language%3AVimL+path%3A%2Fautoload&type=Code&ref=advsearch&l=&l=), I found that they use the `complete()` built-in function instead of overriding the user-designated 'completefunc' setting: https://github.com/heavenshell/vim-flood/blob/2bd8580642c56c2a090a8e44cc768e98019310be/autoload/flood/complete.vim This allows us to add `+=menuone` before calling `complete()` and remove the setting afterwards. Using `complete()` seems like the way to go here, so it looks like I'm going to have to refactor the code to do that instead in order to get "menuone" to work. The way I originally wrote the program was intuitive at the time. I'm glad I did it that way, because it provided me with the knowledge of how to remap the built-in completion mappings in Auditory.vim. Will have to try that out at some point.
-rw-r--r--autoload/gitcha.vim3
1 files changed, 3 insertions, 0 deletions
diff --git a/autoload/gitcha.vim b/autoload/gitcha.vim
index 7ed45c7..e5543f7 100644
--- a/autoload/gitcha.vim
+++ b/autoload/gitcha.vim
@@ -1,6 +1,7 @@
" Save user-defined completefunc so it 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(findstart, base)
@@ -16,6 +17,7 @@ function! gitcha#GitSHAComplete(findstart, base)
" Restore user completion function
let &completefunc = s:old_completefunc
+ " let &completeopt = s:old_completeopt
" Match Git SHAs in the current repository
let matches = []
@@ -57,5 +59,6 @@ endfunction
" Allow mappings to initiate completion
function! gitcha#StartGitSHACompletion()
set completefunc=gitcha#GitSHAComplete
+ set completeopt=menu,menuone,preview
return "\<C-x>\<C-u>"
endfunction