diff options
author | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2017-06-25 12:43:26 +0900 |
---|---|---|
committer | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2017-06-25 12:43:26 +0900 |
commit | d19ed16ee619409390b21607070c379862734601 (patch) | |
tree | 28cb19f33fcf276f3de3c0f57b67bd15b739db3d /autoload | |
parent | 7704e35133ee19b27aa83f290a7c3ef66c22b9ee (diff) | |
download | deoplete.nvim-d19ed16ee619409390b21607070c379862734601.zip |
Fix #499 improve manual completion
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/deoplete.vim | 3 | ||||
-rw-r--r-- | autoload/deoplete/handler.vim | 43 | ||||
-rw-r--r-- | autoload/deoplete/util.vim | 14 |
3 files changed, 25 insertions, 35 deletions
diff --git a/autoload/deoplete.vim b/autoload/deoplete.vim index d2583b2..7ed9e09 100644 --- a/autoload/deoplete.vim +++ b/autoload/deoplete.vim @@ -39,8 +39,7 @@ function! deoplete#manual_complete(...) abort endif " Start complete. - return (pumvisible() ? "\<C-e>" : '') - \ . "\<C-r>=deoplete#mapping#_rpcrequest_wrapper(" + return "\<C-r>=deoplete#mapping#_rpcrequest_wrapper(" \ . string(get(a:000, 0, [])) . ")\<CR>" endfunction function! deoplete#close_popup() abort diff --git a/autoload/deoplete/handler.vim b/autoload/deoplete/handler.vim index 2e3a052..ad6d842 100644 --- a/autoload/deoplete/handler.vim +++ b/autoload/deoplete/handler.vim @@ -45,8 +45,11 @@ function! s:do_complete(timer) abort return endif + let s:prev_completion.event = context.event + let s:prev_completion.candidates = context.candidates + let s:prev_completion.complete_position = getpos('.') + if context.event ==# 'Manual' - " Disable the manual completion let context.event = '' elseif !exists('g:deoplete#_saved_completeopt') call deoplete#mapping#_set_completeopt() @@ -61,9 +64,6 @@ function! s:do_complete(timer) abort let &l:omnifunc = 'deoplete#mapping#_completefunc' call feedkeys("\<C-x>\<C-o>", 'n') endif - - let s:prev_completion.candidates = context.candidates - let s:prev_completion.complete_position = getpos('.') endfunction function! s:timer_begin() abort @@ -75,7 +75,9 @@ function! s:timer_begin() abort let s:completion_timer = timer_start(delay, \ function('s:do_complete'), {'repeat': -1}) - let s:prev_completion = { 'complete_position': [], 'candidates': [] } + let s:prev_completion = { + \ 'complete_position': [], 'candidates': [], 'event': '' + \ } endfunction function! s:timer_end() abort if !exists('s:completion_timer') @@ -123,21 +125,24 @@ function! s:completion_begin(event) abort return endif - " Call omni completion - for filetype in context.filetypes - for pattern in deoplete#util#convert2list( - \ deoplete#util#get_buffer_config(filetype, - \ 'b:deoplete_omni_patterns', - \ 'g:deoplete#omni_patterns', - \ 'g:deoplete#_omni_patterns')) - if pattern !=# '' && &l:omnifunc !=# '' - \ && context.input =~# '\%('.pattern.'\)$' - call deoplete#mapping#_set_completeopt() - call feedkeys("\<C-x>\<C-o>", 'n') - return - endif + if exists('s:prev_completion') && s:prev_completion.event !=# 'Manual' + " Call omni completion + for filetype in context.filetypes + for pattern in deoplete#util#convert2list( + \ deoplete#util#get_buffer_config(filetype, + \ 'b:deoplete_omni_patterns', + \ 'g:deoplete#omni_patterns', + \ 'g:deoplete#_omni_patterns')) + if pattern !=# '' && &l:omnifunc !=# '' + \ && context.input =~# '\%('.pattern.'\)$' + let g:deoplete#_context.candidates = [] + call deoplete#mapping#_set_completeopt() + call feedkeys("\<C-x>\<C-o>", 'n') + return + endif + endfor endfor - endfor + endif call rpcnotify(g:deoplete#_channel_id, \ 'deoplete_auto_completion_begin', context) diff --git a/autoload/deoplete/util.vim b/autoload/deoplete/util.vim index eb3f389..0dd53c4 100644 --- a/autoload/deoplete/util.vim +++ b/autoload/deoplete/util.vim @@ -135,20 +135,6 @@ function! deoplete#util#uniq(list) abort return map(list, 'v:val[0]') endfunction -function! deoplete#util#redir(cmd) abort - if exists('*execute') - return execute(a:cmd) - else - let [save_verbose, save_verbosefile] = [&verbose, &verbosefile] - set verbose=0 verbosefile= - redir => res - silent! execute a:cmd - redir END - let [&verbose, &verbosefile] = [save_verbose, save_verbosefile] - return res - endif -endfunction - function! deoplete#util#get_syn_names() abort if col('$') >= 200 return [] |