summaryrefslogtreecommitdiff
path: root/autoload/deoplete/mapping.vim
blob: ddf591ec927c7306361d3b3f522e3e8e63f53a1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"=============================================================================
" FILE: mapping.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" License: MIT license
"=============================================================================

function! deoplete#mapping#_init() abort
  inoremap <silent> <Plug>_
        \ <C-r>=deoplete#mapping#_do_complete(g:deoplete#_context)<CR>
  inoremap <silent> <Plug>(deoplete_auto_refresh)
        \ <C-r>=deoplete#refresh()<CR>
endfunction

function! deoplete#mapping#_do_complete(context) abort
  if b:changedtick == get(a:context, 'changedtick', -1)
        \ && mode() ==# 'i'
    call complete(a:context.complete_position + 1, a:context.candidates)
  endif

  return ''
endfunction
function! deoplete#mapping#_set_completeopt() abort
  if exists('g:deoplete#_saved_completeopt')
    return
  endif
  let g:deoplete#_saved_completeopt = &completeopt
  set completeopt-=longest
  set completeopt+=menuone
  set completeopt-=menu
  if &completeopt !~# 'noinsert\|noselect'
    set completeopt+=noselect
  endif
endfunction
function! deoplete#mapping#_rpcnotify_wrapper(sources) abort
  call rpcrequest(g:deoplete#_channel_id,
        \ 'deoplete_manual_completion_begin',
        \ deoplete#init#_context('Manual', a:sources))
  return ''
endfunction