From ada81e90271441c3605d1f5e998a8015f5ae258d Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Tue, 10 Nov 2020 23:37:27 +0900 Subject: Add recently_used sort feature --- autoload/deoplete/handler.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'autoload/deoplete/handler.vim') diff --git a/autoload/deoplete/handler.vim b/autoload/deoplete/handler.vim index b1895f1..e355063 100644 --- a/autoload/deoplete/handler.vim +++ b/autoload/deoplete/handler.vim @@ -363,11 +363,27 @@ endfunction function! s:on_complete_done() abort if get(v:completed_item, 'word', '') ==# '' + \ || !has_key(g:deoplete#_context, 'complete_str') return endif call deoplete#handler#_skip_next_completion() + let max_used = 100 + let g:deoplete#_recently_used = insert( + \ g:deoplete#_recently_used, + \ tolower(v:completed_item.word), + \ ) + let min_pattern_length = deoplete#custom#_get_option('min_pattern_length') + if len(g:deoplete#_context['complete_str']) > min_pattern_length + let g:deoplete#_recently_used = insert( + \ g:deoplete#_recently_used, + \ tolower(g:deoplete#_context['complete_str']), + \ ) + endif + let g:deoplete#_recently_used = deoplete#util#uniq( + \ g:deoplete#_recently_used)[: max_used] + let user_data = get(v:completed_item, 'user_data', '') if type(user_data) !=# v:t_string || user_data ==# '' return -- cgit v1.2.3