summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'autoload')
-rw-r--r--autoload/deoplete.vim45
-rw-r--r--autoload/deoplete/handler.vim4
-rw-r--r--autoload/deoplete/init.vim2
-rw-r--r--autoload/deoplete/mapping.vim41
-rw-r--r--autoload/deoplete/mappings.vim71
5 files changed, 96 insertions, 67 deletions
diff --git a/autoload/deoplete.vim b/autoload/deoplete.vim
index c6d58d6..96975fd 100644
--- a/autoload/deoplete.vim
+++ b/autoload/deoplete.vim
@@ -31,4 +31,49 @@ function! deoplete#enable_logging(level, logfile) abort "{{{
\ 'deoplete_enable_logging', a:level, a:logfile)
endfunction"}}}
+function! deoplete#manual_complete(...) abort "{{{
+ if deoplete#initialize()
+ return
+ endif
+
+ " Start complete.
+ return (pumvisible() ? "\<C-e>" : '')
+ \ . "\<C-r>=deoplete#mapping#_rpcnotify_wrapper("
+ \ . string(get(a:000, 0, [])) . ")\<CR>"
+endfunction"}}}
+function! deoplete#close_popup() abort "{{{
+ let g:deoplete#_context.position = getpos('.')
+ return pumvisible() ? "\<C-y>" : ''
+endfunction"}}}
+function! deoplete#smart_close_popup() abort "{{{
+ let g:deoplete#_context.position = getpos('.')
+ return pumvisible() ? "\<C-e>" : ''
+endfunction"}}}
+function! deoplete#cancel_popup() abort "{{{
+ let g:deoplete#_context.position = getpos('.')
+ return pumvisible() ? "\<C-e>" : ''
+endfunction"}}}
+function! deoplete#refresh() abort "{{{
+ let g:deoplete#_context.refresh = 1
+ if g:deoplete#_context.event ==# 'Manual'
+ let g:deoplete#_context.event = 'Refresh'
+ endif
+ return pumvisible() ? "\<C-e>" : ''
+endfunction"}}}
+
+function! deoplete#undo_completion() abort "{{{
+ if !exists('v:completed_item') || empty(v:completed_item)
+ return ''
+ endif
+
+ let input = deoplete#util#get_input('')
+ if strridx(input, v:completed_item.word) !=
+ \ len(input) - len(v:completed_item.word)
+ return ''
+ endif
+
+ return deoplete#mapping#smart_close_popup() .
+ \ repeat("\<C-h>", strchars(v:completed_item.word))
+endfunction"}}}
+
" vim: foldmethod=marker
diff --git a/autoload/deoplete/handler.vim b/autoload/deoplete/handler.vim
index 45d9a6b..fb27120 100644
--- a/autoload/deoplete/handler.vim
+++ b/autoload/deoplete/handler.vim
@@ -45,14 +45,14 @@ function! s:completion_begin(event) abort "{{{
\ 'g:deoplete#_omni_patterns'))
if pattern != '' && &l:omnifunc != ''
\ && context.input =~# '\%('.pattern.'\)$'
- call deoplete#mappings#_set_completeopt()
+ call deoplete#mapping#_set_completeopt()
call feedkeys("\<C-x>\<C-o>", 'n')
return
endif
endfor
endfor
- call deoplete#mappings#_set_completeopt()
+ call deoplete#mapping#_set_completeopt()
call rpcnotify(g:deoplete#_channel_id,
\ 'deoplete_auto_completion_begin', context)
endfunction"}}}
diff --git a/autoload/deoplete/init.vim b/autoload/deoplete/init.vim
index c80cd4e..658bf2d 100644
--- a/autoload/deoplete/init.vim
+++ b/autoload/deoplete/init.vim
@@ -72,7 +72,7 @@ function! deoplete#init#_initialize() abort "{{{
return 1
endif
- call deoplete#mappings#_init()
+ call deoplete#mapping#_init()
call deoplete#init#_variables()
let s:is_enabled = g:deoplete#enable_at_startup
diff --git a/autoload/deoplete/mapping.vim b/autoload/deoplete/mapping.vim
new file mode 100644
index 0000000..ad191c1
--- /dev/null
+++ b/autoload/deoplete/mapping.vim
@@ -0,0 +1,41 @@
+"=============================================================================
+" FILE: mapping.vim
+" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
+" License: MIT license
+"=============================================================================
+
+function! deoplete#mapping#_init() abort "{{{
+ inoremap <silent> <Plug>(deoplete_start_complete)
+ \ <C-r>=deoplete#mapping#_do_complete(g:deoplete#_context)<CR>
+ inoremap <silent> <Plug>(deoplete_auto_refresh)
+ \ <C-r>=deoplete#mapping#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"}}}
+
+" vim: foldmethod=marker
diff --git a/autoload/deoplete/mappings.vim b/autoload/deoplete/mappings.vim
index c4fc223..30432a0 100644
--- a/autoload/deoplete/mappings.vim
+++ b/autoload/deoplete/mappings.vim
@@ -4,84 +4,27 @@
" License: MIT license
"=============================================================================
-function! deoplete#mappings#_init() abort "{{{
- inoremap <silent> <Plug>(deoplete_start_complete)
- \ <C-r>=deoplete#mappings#_do_complete(g:deoplete#_context)<CR>
- inoremap <silent> <Plug>(deoplete_auto_refresh)
- \ <C-r>=deoplete#mappings#refresh()<CR>
-endfunction"}}}
-
-function! deoplete#mappings#_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#mappings#_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"}}}
+" For compatibility.
function! deoplete#mappings#manual_complete(...) abort "{{{
- if deoplete#initialize()
- return
- endif
-
- " Start complete.
- return (pumvisible() ? "\<C-e>" : '')
- \ . "\<C-r>=deoplete#mappings#_rpcnotify_wrapper("
- \ . string(get(a:000, 0, [])) . ")\<CR>"
-endfunction"}}}
-function! deoplete#mappings#_rpcnotify_wrapper(sources) abort "{{{
- call rpcrequest(g:deoplete#_channel_id,
- \ 'deoplete_manual_completion_begin',
- \ deoplete#init#_context('Manual', a:sources))
- return ''
+ return call('deoplete#manual_complete', a:000)
endfunction"}}}
function! deoplete#mappings#close_popup() abort "{{{
- let g:deoplete#_context.position = getpos('.')
- return pumvisible() ? "\<C-y>" : ''
+ return deoplete#close_popup()
endfunction"}}}
function! deoplete#mappings#smart_close_popup() abort "{{{
- let g:deoplete#_context.position = getpos('.')
- return pumvisible() ? "\<C-e>" : ''
+ return deoplete#smart_close_popup()
endfunction"}}}
function! deoplete#mappings#cancel_popup() abort "{{{
- let g:deoplete#_context.position = getpos('.')
- return pumvisible() ? "\<C-e>" : ''
+ return deoplete#cancel_popup()
endfunction"}}}
function! deoplete#mappings#refresh() abort "{{{
- let g:deoplete#_context.refresh = 1
- if g:deoplete#_context.event ==# 'Manual'
- let g:deoplete#_context.event = 'Refresh'
- endif
- return pumvisible() ? "\<C-e>" : ''
+ return deoplete#refresh()
endfunction"}}}
function! deoplete#mappings#undo_completion() abort "{{{
- if !exists('v:completed_item') || empty(v:completed_item)
- return ''
- endif
-
- let input = deoplete#util#get_input('')
- if strridx(input, v:completed_item.word) !=
- \ len(input) - len(v:completed_item.word)
- return ''
- endif
-
- return deoplete#mappings#smart_close_popup() .
- \ repeat("\<C-h>", strchars(v:completed_item.word))
+ return deoplete#undo_completion()
endfunction"}}}
" vim: foldmethod=marker