Skip to content

Commit

Permalink
Add deoplete#send_event()
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Mar 12, 2018
1 parent b09bb1f commit c3c9406
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions autoload/deoplete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ function! deoplete#enable_logging(level, logfile) abort
call deoplete#util#rpcnotify('deoplete_enable_logging', {})
endfunction

function! deoplete#send_event(event) abort
call deoplete#util#rpcnotify('deoplete_on_event',
\ deoplete#init#_context(a:event, []))
endfunction

function! deoplete#manual_complete(...) abort
if !deoplete#is_enabled()
return ''
Expand Down
3 changes: 1 addition & 2 deletions autoload/deoplete/handler.vim
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ endfunction

function! s:define_on_event(event) abort
execute 'autocmd deoplete' a:event
\ '* call deoplete#util#rpcnotify("deoplete_on_event",'
\.'deoplete#init#_context('.string(a:event).', []))'
\ '* call deoplete#send_event('.string(a:event).')'
endfunction

function! s:on_insert_leave() abort
Expand Down
9 changes: 7 additions & 2 deletions doc/deoplete.txt
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ deoplete#enable_logging({level}, {logfile})
|deoplete-source-attribute-is_debug_enabled| to debug the
sources.

*deoplete#send_event()*
deoplete#send_event({event})
Call |deoplete-source-attribute-on_event| manually.
{event} is event name.

------------------------------------------------------------------------------
KEY MAPPINGS *deoplete-key-mappings*
Expand Down Expand Up @@ -953,8 +957,9 @@ on_post_filter

*deoplete-source-attribute-on_event*
on_event (Function) (Optional)
It is called when |BufRead|, |BufNewFile|, |BufWritePost|,
|VimLeavePre| or deoplete is initialized.
It is called when |BufNew|, |BufNewFile|, |BufWritePost|,
|VimLeavePre| or |deoplete#send_event()| or deoplete is
initialized.
It is useful to make cache.
It takes {self} and {context} as its parameter.

Expand Down

0 comments on commit c3c9406

Please sign in to comment.