diff options
author | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2020-11-10 23:37:27 +0900 |
---|---|---|
committer | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2020-11-17 19:09:04 +0900 |
commit | ada81e90271441c3605d1f5e998a8015f5ae258d (patch) | |
tree | 377a7646eada185ca4300e25fd3fbd2bbe45d6e4 /autoload/deoplete | |
parent | ddfc3eeb866c64e025a9f1e132b37b199a44973f (diff) | |
download | deoplete.nvim-ada81e90271441c3605d1f5e998a8015f5ae258d.zip |
Add recently_used sort feature
Diffstat (limited to 'autoload/deoplete')
-rw-r--r-- | autoload/deoplete/handler.vim | 16 | ||||
-rw-r--r-- | autoload/deoplete/init.vim | 1 |
2 files changed, 17 insertions, 0 deletions
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 diff --git a/autoload/deoplete/init.vim b/autoload/deoplete/init.vim index d2380e7..cd9ccfa 100644 --- a/autoload/deoplete/init.vim +++ b/autoload/deoplete/init.vim @@ -112,6 +112,7 @@ function! s:init_internal_variables() abort call deoplete#init#_prev_completion() let g:deoplete#_context = {} + let g:deoplete#_recently_used = [] if !exists('g:deoplete#_logging') let g:deoplete#_logging = {} |