Permalink
Browse files

Fix timer_start callbak

  • Loading branch information...
1 parent b50ad11 commit 0d8c416d3b7ac2c271fb28c91758e1f15b925e2c @h-michael h-michael committed Dec 13, 2016
View
@@ -5,9 +5,10 @@ language: python
python:
- 3.3
- 3.4
+ - 3.5
install:
- - pip install neovim flake8 nose
+ - pip install neovim flake8 nose mock pytest mypy-lang
before_script:
- git clone https://github.com/syngan/vim-vimlint /tmp/vim-vimlint
View
@@ -2,6 +2,7 @@ test: vim-themis
vim-themis/bin/themis --reporter spec test
nosetests -v rplugin/python3
flake8 rplugin/
+ mypy --silent-imports rplugin/python3/deoplete
# Use existing vim-themis install from ~/.vim, or clone it.
vim-themis:
View
@@ -17,7 +17,7 @@ See [requirements](#requirements) if you aren't sure whether you have this.
1. Extract the files and put them in your Neovim directory
(usually `$XDG_CONFIG_HOME/nvim/`).
2. Execute the `:UpdateRemotePlugins` and restart Neovim.
-3. Call `deoplete#enable()` or set "let g:deoplete#enable_at_startup = 1" in
+3. Write `call deoplete#enable()` or `let g:deoplete#enable_at_startup = 1` in
your `init.vim`
@@ -52,8 +52,16 @@ If you want to read the Neovim-python/python3 interface install documentation,
you should read `:help provider-python` and the Wiki.
https://github.com/zchee/deoplete-jedi/wiki/Setting-up-Python-for-Neovim
+## Note: Python3 must be enabled before updating remote plugins
+If Deoplete was installed prior to Python support being added to Neovim,
+`:UpdateRemotePlugins` should be executed manually in order to enable
+auto-completion.
+
## Screenshots
+Deoplete for JavaScript
+https://www.youtube.com/watch?v=oanoPTpiSF4
+
![File Name Completion](https://cloud.githubusercontent.com/assets/7141867/11717027/a99cac54-9f73-11e5-91ce-bce9274692e4.png)
![Omni Completion](https://cloud.githubusercontent.com/assets/7141867/11717030/ae809a28-9f73-11e5-8c12-79fe9c460401.png)
View
@@ -4,24 +4,24 @@
" License: MIT license
"=============================================================================
-function! deoplete#initialize() abort "{{{
+function! deoplete#initialize() abort
return deoplete#init#_initialize()
-endfunction"}}}
-function! deoplete#enable() abort "{{{
+endfunction
+function! deoplete#enable() abort
if deoplete#initialize()
return 1
endif
return deoplete#init#_enable()
-endfunction"}}}
-function! deoplete#disable() abort "{{{
+endfunction
+function! deoplete#disable() abort
return deoplete#init#_disable()
-endfunction"}}}
-function! deoplete#toggle() abort "{{{
+endfunction
+function! deoplete#toggle() abort
return deoplete#init#_is_enabled() ?
\ deoplete#disable() : deoplete#enable()
-endfunction"}}}
+endfunction
-function! deoplete#enable_logging(level, logfile) abort "{{{
+function! deoplete#enable_logging(level, logfile) abort
if !exists('g:deoplete#_channel_id')
" Enable to allow logging before completions start.
if deoplete#init#_channel()
@@ -31,9 +31,9 @@ function! deoplete#enable_logging(level, logfile) abort "{{{
call rpcrequest(g:deoplete#_channel_id,
\ 'deoplete_enable_logging', a:level, a:logfile)
-endfunction"}}}
+endfunction
-function! deoplete#manual_complete(...) abort "{{{
+function! deoplete#manual_complete(...) abort
if deoplete#initialize()
return
endif
@@ -42,28 +42,28 @@ function! deoplete#manual_complete(...) abort "{{{
return (pumvisible() ? "\<C-e>" : '')
\ . "\<C-r>=deoplete#mapping#_rpcnotify_wrapper("
\ . string(get(a:000, 0, [])) . ")\<CR>"
-endfunction"}}}
-function! deoplete#close_popup() abort "{{{
+endfunction
+function! deoplete#close_popup() abort
let g:deoplete#_context.position = getpos('.')
return pumvisible() ? "\<C-y>" : ''
-endfunction"}}}
-function! deoplete#smart_close_popup() abort "{{{
+endfunction
+function! deoplete#smart_close_popup() abort
let g:deoplete#_context.position = getpos('.')
return pumvisible() ? "\<C-e>" : ''
-endfunction"}}}
-function! deoplete#cancel_popup() abort "{{{
+endfunction
+function! deoplete#cancel_popup() abort
let g:deoplete#_context.position = getpos('.')
return pumvisible() ? "\<C-e>" : ''
-endfunction"}}}
-function! deoplete#refresh() abort "{{{
+endfunction
+function! deoplete#refresh() abort
let g:deoplete#_context.refresh = 1
if get(g:deoplete#_context, 'event', '') ==# 'Manual'
let g:deoplete#_context.event = 'Refresh'
endif
return pumvisible() ? "\<C-e>" : ''
-endfunction"}}}
+endfunction
-function! deoplete#undo_completion() abort "{{{
+function! deoplete#undo_completion() abort
if !exists('v:completed_item') || empty(v:completed_item)
return ''
endif
@@ -76,6 +76,4 @@ function! deoplete#undo_completion() abort "{{{
return deoplete#smart_close_popup() .
\ repeat("\<C-h>", strchars(v:completed_item.word))
-endfunction"}}}
-
-" vim: foldmethod=marker
+endfunction
@@ -4,30 +4,28 @@
" License: MIT license
"=============================================================================
-function! deoplete#custom#get() abort "{{{
+function! deoplete#custom#get() abort
if !exists('s:custom')
let s:custom = {}
let s:custom._ = {}
endif
return s:custom
-endfunction"}}}
+endfunction
-function! deoplete#custom#get_source_var(source_name) abort "{{{
+function! deoplete#custom#get_source_var(source_name) abort
let custom = deoplete#custom#get()
if !has_key(custom, a:source_name)
let custom[a:source_name] = {}
endif
return custom[a:source_name]
-endfunction"}}}
+endfunction
-function! deoplete#custom#set(source_name, option_name, value) abort "{{{
+function! deoplete#custom#set(source_name, option_name, value) abort
for key in split(a:source_name, '\s*,\s*')
let custom_source = deoplete#custom#get_source_var(key)
let custom_source[a:option_name] = a:value
endfor
-endfunction"}}}
-
-" vim: foldmethod=marker
+endfunction
@@ -4,7 +4,7 @@
" License: MIT license
"=============================================================================
-function! deoplete#handler#_init() abort "{{{
+function! deoplete#handler#_init() abort
augroup deoplete
autocmd!
autocmd InsertLeave * call s:on_insert_leave()
@@ -15,42 +15,41 @@ function! deoplete#handler#_init() abort "{{{
autocmd InsertEnter * call s:completion_check('InsertEnter')
augroup END
- for event in [
- \ 'BufNewFile', 'BufNew', 'BufRead', 'BufWritePost'
- \ ]
+ for event in ['BufNewFile', 'BufRead', 'BufWritePost']
execute 'autocmd deoplete' event '* call s:on_event('.string(event).')'
endfor
- call s:on_event('')
-endfunction"}}}
+ call s:on_event('Init')
+endfunction
-function! s:completion_delayed(timer) abort "{{{
- let timer = s:timer
- unlet! s:timer
- call s:completion_begin(timer.event)
-endfunction"}}}
-
-function! s:completion_check(event) abort "{{{
+function! s:completion_check(event) abort
let delay = get(g:deoplete#_context, 'refresh', 0) ?
\ g:deoplete#auto_refresh_delay : g:deoplete#auto_complete_delay
if has('timers') && delay > 0
if exists('s:timer')
call timer_stop(s:timer.id)
endif
- if a:event != 'Manual'
- let s:timer = { 'event': a:event }
- let s:timer.id = timer_start(delay, 's:completion_delayed')
+ if a:event !=# 'Manual'
+ let s:timer = { 'event': a:event, 'changedtick': b:changedtick }
+ let s:timer.id = timer_start(delay, function('s:completion_delayed'))
return
endif
endif
return s:completion_begin(a:event)
-endfunction"}}}
+endfunction
-function! s:completion_begin(event) abort "{{{
- let context = deoplete#init#_context(a:event, [])
+function! s:completion_delayed(timer) abort
+ let timer = s:timer
+ unlet! s:timer
+ if b:changedtick == timer.changedtick
+ call s:completion_begin(timer.event)
+ endif
+endfunction
+function! s:completion_begin(event) abort
+ let context = deoplete#init#_context(a:event, [])
if s:is_skip(a:event, context)
return
endif
@@ -79,9 +78,9 @@ function! s:completion_begin(event) abort "{{{
call deoplete#mapping#_set_completeopt()
call rpcnotify(g:deoplete#_channel_id,
\ 'deoplete_auto_completion_begin', context)
-endfunction"}}}
-function! s:is_skip(event, context) abort "{{{
- if s:is_skip_textwidth(deoplete#util#get_input(a:event))
+endfunction
+function! s:is_skip(event, context) abort
+ if s:is_skip_text(a:event)
return 1
endif
@@ -110,35 +109,42 @@ function! s:is_skip(event, context) abort "{{{
endif
return 0
-endfunction"}}}
-function! s:is_skip_textwidth(input) abort "{{{
- let displaywidth = strdisplaywidth(a:input) + 1
+endfunction
+function! s:is_skip_text(event) abort
+ let input = deoplete#util#get_input(a:event)
+ let displaywidth = strdisplaywidth(input) + 1
if &l:formatoptions =~# '[tca]' && &l:textwidth > 0
\ && displaywidth >= &l:textwidth
if &l:formatoptions =~# '[ta]'
\ || !empty(filter(deoplete#util#get_syn_names(),
- \ 'v:val ==# "Comment"'))
+ \ "v:val ==# 'Comment'"))
return 1
endif
endif
- return !pumvisible() && virtcol('.') != displaywidth
-endfunction"}}}
-function! s:on_event(event) abort "{{{
+ let skip_chars = deoplete#util#get_simple_buffer_config(
+ \ 'b:deoplete_skip_chars', 'g:deoplete#skip_chars')
+
+ return (!pumvisible() && virtcol('.') != displaywidth)
+ \ || (a:event !=# 'Manual' && input != ''
+ \ && index(skip_chars, input[-1:]) >= 0)
+endfunction
+
+function! s:on_event(event) abort
let context = deoplete#init#_context(a:event, [])
call rpcnotify(g:deoplete#_channel_id, 'deoplete_on_event', context)
-endfunction"}}}
+endfunction
-function! s:on_insert_leave() abort "{{{
+function! s:on_insert_leave() abort
if exists('g:deoplete#_saved_completeopt')
let &completeopt = g:deoplete#_saved_completeopt
unlet g:deoplete#_saved_completeopt
endif
let g:deoplete#_context = {}
-endfunction"}}}
+endfunction
-function! s:complete_done() abort "{{{
+function! s:complete_done() abort
if get(v:completed_item, 'word', '') != ''
let word = v:completed_item.word
if !has_key(g:deoplete#_rank, word)
@@ -149,17 +155,15 @@ function! s:complete_done() abort "{{{
endif
let g:deoplete#_context.position = getpos('.')
-endfunction"}}}
+endfunction
-function! s:on_insert_char_pre() abort "{{{
+function! s:on_insert_char_pre() abort
if !pumvisible()
\ || !g:deoplete#enable_refresh_always
- \ || s:is_skip_textwidth(deoplete#util#get_input('InsertCharPre'))
+ \ || s:is_skip_text('InsertCharPre')
return 1
endif
" Auto refresh
call feedkeys("\<Plug>(deoplete_auto_refresh)")
-endfunction"}}}
-
-" vim: foldmethod=marker
+endfunction
Oops, something went wrong.

0 comments on commit 0d8c416

Please sign in to comment.