summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/deoplete.vim4
-rw-r--r--autoload/deoplete/handler.vim66
-rw-r--r--autoload/deoplete/init.vim10
-rw-r--r--autoload/deoplete/mapping.vim5
-rw-r--r--rplugin/python3/deoplete/deoplete.py8
5 files changed, 46 insertions, 47 deletions
diff --git a/autoload/deoplete.vim b/autoload/deoplete.vim
index 6a4c50d..117ed60 100644
--- a/autoload/deoplete.vim
+++ b/autoload/deoplete.vim
@@ -42,9 +42,9 @@ endfunction
function! deoplete#send_event(event, ...) abort
let g:deoplete#_cached_context = deoplete#init#_cached_context()
- let sources = get(a:000, 0, [])
+ let sources = deoplete#util#convert2list(get(a:000, 0, []))
call deoplete#util#rpcnotify('deoplete_on_event',
- \ deoplete#init#_context(a:event, sources))
+ \ {'event': a:event, 'sources': sources})
endfunction
function! deoplete#manual_complete(...) abort
diff --git a/autoload/deoplete/handler.vim b/autoload/deoplete/handler.vim
index ddd52b3..90de2ce 100644
--- a/autoload/deoplete/handler.vim
+++ b/autoload/deoplete/handler.vim
@@ -77,6 +77,35 @@ function! deoplete#handler#_do_complete() abort
endif
endfunction
+function! deoplete#handler#_check_omnifunc(context) abort
+ let prev = g:deoplete#_prev_completion
+ let blacklist = ['LanguageClient#complete']
+ if a:context.event ==# 'Manual'
+ \ || &l:omnifunc ==# ''
+ \ || index(blacklist, &l:omnifunc) >= 0
+ \ || prev.input ==# a:context.input
+ return
+ endif
+
+ for filetype in a:context.filetypes
+ for pattern in deoplete#util#convert2list(
+ \ deoplete#custom#_get_filetype_option(
+ \ 'omni_patterns', filetype, ''))
+ if pattern !=# '' && a:context.input =~# '\%('.pattern.'\)$'
+ let g:deoplete#_context.candidates = []
+
+ let prev.event = a:context.event
+ let prev.input = a:context.input
+ let prev.candidates = []
+
+ call deoplete#mapping#_set_completeopt()
+ call feedkeys("\<C-x>\<C-o>", 'in')
+ return 1
+ endif
+ endfor
+ endfor
+endfunction
+
function! s:completion_timer_start(event) abort
if exists('s:completion_timer')
call s:completion_timer_stop()
@@ -136,17 +165,12 @@ function! s:completion_begin(event) abort
return
endif
- let context = deoplete#init#_context(a:event, [])
- if context['event'] !=# 'Async'
+ if a:event !=# 'Async'
call deoplete#init#_prev_completion()
endif
- if s:check_omnifunc(context)
- return
- endif
-
call deoplete#util#rpcnotify(
- \ 'deoplete_auto_completion_begin', context)
+ \ 'deoplete_auto_completion_begin', {'event': a:event})
endfunction
function! s:is_skip(event) abort
if s:is_skip_text(a:event)
@@ -191,34 +215,6 @@ function! s:is_skip_text(event) abort
\ || (a:event !=# 'Manual' && input !=# ''
\ && index(skip_chars, input[-1:]) >= 0)
endfunction
-function! s:check_omnifunc(context) abort
- let prev = g:deoplete#_prev_completion
- let blacklist = ['LanguageClient#complete']
- if a:context.event ==# 'Manual'
- \ || &l:omnifunc ==# ''
- \ || index(blacklist, &l:omnifunc) >= 0
- \ || prev.input ==# a:context.input
- return
- endif
-
- for filetype in a:context.filetypes
- for pattern in deoplete#util#convert2list(
- \ deoplete#custom#_get_filetype_option(
- \ 'omni_patterns', filetype, ''))
- if pattern !=# '' && a:context.input =~# '\%('.pattern.'\)$'
- let g:deoplete#_context.candidates = []
-
- let prev.event = a:context.event
- let prev.input = a:context.input
- let prev.candidates = []
-
- call deoplete#mapping#_set_completeopt()
- call feedkeys("\<C-x>\<C-o>", 'in')
- return 1
- endif
- endfor
- endfor
-endfunction
function! s:define_on_event(event) abort
if !exists('##' . a:event)
diff --git a/autoload/deoplete/init.vim b/autoload/deoplete/init.vim
index ea1db3a..d859e55 100644
--- a/autoload/deoplete/init.vim
+++ b/autoload/deoplete/init.vim
@@ -218,13 +218,6 @@ function! deoplete#init#_context(event, sources) abort
let [filetype, filetypes, same_filetypes] =
\ deoplete#util#get_context_filetype(input, a:event)
- let sources = deoplete#util#convert2list(a:sources)
- if a:event !=# 'Manual' && empty(sources)
- " Use default sources
- let sources = deoplete#custom#_get_filetype_option(
- \ 'sources', filetype, [])
- endif
-
let event = (deoplete#util#get_prev_event() ==# 'Refresh') ?
\ 'Manual' : a:event
@@ -240,7 +233,8 @@ function! deoplete#init#_context(event, sources) abort
\ 'filetype': filetype,
\ 'filetypes': filetypes,
\ 'same_filetypes': same_filetypes,
- \ 'sources': sources,
+ \ 'sources': deoplete#custom#_get_filetype_option(
+ \ 'sources', filetype, []),
\ 'max_abbr_width': max_width,
\ 'max_kind_width': max_width,
\ 'max_menu_width': max_width,
diff --git a/autoload/deoplete/mapping.vim b/autoload/deoplete/mapping.vim
index 7071a94..b3f2f60 100644
--- a/autoload/deoplete/mapping.vim
+++ b/autoload/deoplete/mapping.vim
@@ -46,7 +46,10 @@ endfunction
function! deoplete#mapping#_rpcrequest_wrapper(sources) abort
return deoplete#util#rpcnotify(
\ 'deoplete_manual_completion_begin',
- \ deoplete#init#_context('Manual', a:sources))
+ \ {
+ \ 'event': 'Manual',
+ \ 'sources': deoplete#util#convert2list(a:sources)
+ \ })
endfunction
function! deoplete#mapping#_undo_completion() abort
if empty(v:completed_item)
diff --git a/rplugin/python3/deoplete/deoplete.py b/rplugin/python3/deoplete/deoplete.py
index fa1b0bb..bdedf9e 100644
--- a/rplugin/python3/deoplete/deoplete.py
+++ b/rplugin/python3/deoplete/deoplete.py
@@ -59,10 +59,16 @@ class Deoplete(logger.LoggingMixin):
logger.setup(self._vim, logging['level'], logging['logfile'])
self.is_debug_enabled = True
- def completion_begin(self, context):
+ def completion_begin(self, user_context):
+ context = self._vim.call('deoplete#init#_context', '', [])
+ context.update(user_context)
+
self.debug('completion_begin (%s): %r',
context['event'], context['input'])
+ if self._vim.call('deoplete#handler#_check_omnifunc', context):
+ return
+
self._check_recache(context)
try: