From bad5f00c445c820c25d0a1da74374d55e62fbce0 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 17 Aug 2015 19:50:23 +0900 Subject: [PATCH] Add experimental completion helper function --- plugin/fzf.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 49ec516..5458896 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -364,6 +364,22 @@ endfunction command! -bang Snippets call s:snippets(0) +" ---------------------------------------------------------------------------- +" Completion helper +" ---------------------------------------------------------------------------- +function! s:complete_insert(data) + execute 'normal!' (empty(s:query) ? 'a' : 'ciW')."\=a:data\" + startinsert! +endfunction + +function! fzf#complete(source, ...) + let s:query = get(a:, 1, expand('')) + call s:fzf({ + \ 'source': a:source, + \ 'sink': function('s:complete_insert'), + \ 'options': '+m -q '.shellescape(s:query)}, 0) +endfunction + " ------------------------------------------------------------------ let &cpo = s:cpo_save unlet s:cpo_save