diff options
author | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2018-12-31 12:51:51 +0900 |
---|---|---|
committer | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2018-12-31 12:51:51 +0900 |
commit | 1f470afc3eb33f9c5abd5fa18ef144e13ea51301 (patch) | |
tree | 53befee189bfac97a672ad2014490a4cb413a752 /autoload/deoplete | |
parent | dc745e2a97025310c5439d304b5a8486550384bc (diff) | |
download | deoplete.nvim-1f470afc3eb33f9c5abd5fa18ef144e13ea51301.zip |
Fix #900 redraw behavior
Diffstat (limited to 'autoload/deoplete')
-rw-r--r-- | autoload/deoplete/handler.vim | 32 | ||||
-rw-r--r-- | autoload/deoplete/init.vim | 1 | ||||
-rw-r--r-- | autoload/deoplete/mapping.vim | 21 |
3 files changed, 43 insertions, 11 deletions
diff --git a/autoload/deoplete/handler.vim b/autoload/deoplete/handler.vim index c360da4..4adaa1f 100644 --- a/autoload/deoplete/handler.vim +++ b/autoload/deoplete/handler.vim @@ -64,6 +64,7 @@ function! deoplete#handler#_do_complete() abort let prev.input = context.input let prev.candidates = context.candidates let prev.complete_position = context.complete_position + let prev.linenr = line('.') if context.event ==# 'Manual' let context.event = '' @@ -109,12 +110,15 @@ function! s:completion_timer_start(event) abort endif let delay = deoplete#custom#_get_option('auto_complete_delay') + " let delay = 1000 if delay > 0 let s:completion_timer = timer_start( \ delay, {-> s:completion_begin(a:event)}) else call s:completion_begin(a:event) endif + + call s:check_prev_completion(a:event) endfunction function! s:completion_timer_stop() abort if !exists('s:completion_timer') @@ -125,6 +129,34 @@ function! s:completion_timer_stop() abort unlet s:completion_timer endfunction +function! s:check_prev_completion(event) abort + let prev = g:deoplete#_prev_completion + if empty(get(prev, 'candidates', [])) + return + endif + + let input = deoplete#util#get_input(a:event) + if prev.linenr != line('.') + \ || (substitute(input, '\w\+$', '', '') !=# + \ substitute(prev.input, '\w\+$', '', '')) + \ || stridx(input, prev.input) != 0 + return + endif + + call deoplete#mapping#_set_completeopt() + let pattern = substitute(input[prev.complete_position :], + \ '\w', '\\w*\0', 'g') + let candidates = filter(copy(prev.candidates), 'v:val.word =~? pattern') + if empty(candidates) + return + endif + let g:deoplete#_filtered_prev = { + \ 'complete_position': prev.complete_position, + \ 'candidates': candidates, + \ } + call feedkeys("\<Plug>+", 'i') +endfunction + function! deoplete#handler#_async_timer_start() abort if exists('s:async_timer') call deoplete#handler#_async_timer_stop() diff --git a/autoload/deoplete/init.vim b/autoload/deoplete/init.vim index 3c5316b..6ad2fe8 100644 --- a/autoload/deoplete/init.vim +++ b/autoload/deoplete/init.vim @@ -231,6 +231,7 @@ function! deoplete#init#_prev_completion() abort let g:deoplete#_prev_completion = { \ 'event': '', \ 'input': '', + \ 'linenr': -1, \ 'candidates': [], \ 'complete_position': -1, \ } diff --git a/autoload/deoplete/mapping.vim b/autoload/deoplete/mapping.vim index 494b8c6..92deb07 100644 --- a/autoload/deoplete/mapping.vim +++ b/autoload/deoplete/mapping.vim @@ -6,25 +6,24 @@ function! deoplete#mapping#_init() abort " Note: The dummy function is needed for cpoptions bug in neovim - inoremap <expr><silent> <Plug>_ deoplete#mapping#_dummy_complete() + inoremap <expr><silent> <Plug>_ + \ "\<C-r>=deoplete#mapping#_complete()\<CR>" + inoremap <expr><silent> <Plug>+ + \ "\<C-r>=deoplete#mapping#_prev_complete()\<CR>" endfunction -function! deoplete#mapping#_dummy_complete() abort - return "\<C-r>=deoplete#mapping#_complete()\<CR>" -endfunction -function! deoplete#mapping#_completefunc(findstart, base) abort - if a:findstart - return g:deoplete#_context.complete_position - else - return g:deoplete#_context.candidates - endif -endfunction function! deoplete#mapping#_complete() abort call complete(g:deoplete#_context.complete_position + 1, \ g:deoplete#_context.candidates) return '' endfunction +function! deoplete#mapping#_prev_complete() abort + call complete(g:deoplete#_filtered_prev.complete_position + 1, + \ g:deoplete#_filtered_prev.candidates) + + return '' +endfunction function! deoplete#mapping#_set_completeopt() abort if exists('g:deoplete#_saved_completeopt') return |