Skip to content

Commit

Permalink
Merge pull request #602 from Shougo/parallel
Browse files Browse the repository at this point in the history
[RFC] Fix #471 Parallel
  • Loading branch information
Shougo committed Feb 4, 2018
2 parents 865747e + e37de74 commit 0a6debf
Show file tree
Hide file tree
Showing 18 changed files with 854 additions and 510 deletions.
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,8 @@ To view the current options, please consult the
## Installation

**Note:** deoplete requires Neovim(latest is recommended) or Vim8 with Python3 and
timers(neovim ver.0.1.5+) enabled. See [requirements](#requirements) if you
aren't sure whether you have this.

1. Extract the files and put them in your Neovim or .vim directory
(usually `$XDG_CONFIG_HOME/nvim/`).
2. Write `call deoplete#enable()` or `let g:deoplete#enable_at_startup = 1` in
your `init.vim`
timers enabled. See [requirements](#requirements) if you aren't sure whether
you have this.


For vim-plug
Expand All @@ -34,6 +29,7 @@ else
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
let g:deoplete#enable_at_startup = 1
```

For dein.vim
Expand All @@ -44,13 +40,22 @@ if !has('nvim')
call dein#add('roxma/nvim-yarp')
call dein#add('roxma/vim-hug-neovim-rpc')
endif
let g:deoplete#enable_at_startup = 1
```

For manual installation(not recommended)

1. Extract the files and put them in your Neovim or .vim directory
(usually `$XDG_CONFIG_HOME/nvim/`).

2. Write `call deoplete#enable()` or `let g:deoplete#enable_at_startup = 1` in
your `init.vim`


## Requirements

deoplete requires Neovim or Vim8 with if\_python3.
If `:echo has("python3")` returns `1`, then you have python 3 support; otherwise, see below.
deoplete requires Neovim or Vim8 with if\_python3. If `:echo has("python3")`
returns `1`, then you have python 3 support; otherwise, see below.

You can enable Python3 interface with pip:

Expand All @@ -76,6 +81,7 @@ auto-completion.
let g:deoplete#enable_at_startup = 1
```


## Sources

deoplete will display completions via `complete()` by default.
Expand Down Expand Up @@ -122,5 +128,4 @@ https://www.youtube.com/watch?v=oanoPTpiSF4

[Register/Extract list completions](https://github.com/camo/6a6df993ad0e05c014c72c8f8702447f9b34ad90/68747470733a2f2f692e696d6775722e636f6d2f5131663731744a2e676966)

### deoplete-fsharp sample ( Enjoy! )
![FSharp completion using deopletefs](https://github.com/callmekohei/deoplete-fsharp/blob/master/pic/sample.gif)
23 changes: 13 additions & 10 deletions autoload/deoplete/handler.vim
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@ function! s:do_complete(timer) abort
return
endif

let prev = g:deoplete#_prev_completion
if context.event !=# 'Manual'
\ && s:prev_completion.complete_position == getpos('.')
\ && s:prev_completion.candidates ==# context.candidates
\ && prev.complete_position == getpos('.')
\ && prev.candidates ==# context.candidates
return
endif

let s:prev_completion.event = context.event
let s:prev_completion.candidates = context.candidates
let s:prev_completion.complete_position = getpos('.')
let prev.event = context.event
let prev.candidates = context.candidates
let prev.complete_position = getpos('.')

if context.event ==# 'Manual'
let context.event = ''
Expand All @@ -83,11 +84,13 @@ function! deoplete#handler#_completion_timer_start() abort
call s:completion_timer_stop()
endif

let delay = max([50, g:deoplete#auto_complete_delay])
let delay = max([20, g:deoplete#auto_complete_delay])
let s:completion_timer = timer_start(delay, function('s:do_complete'))

let s:prev_completion = {
\ 'complete_position': [], 'candidates': [], 'event': ''
let g:deoplete#_prev_completion = {
\ 'complete_position': [],
\ 'candidates': [],
\ 'event': '',
\ }
endfunction
function! s:completion_timer_stop() abort
Expand All @@ -106,7 +109,7 @@ function! deoplete#handler#_async_timer_start() abort

let s:async_timer = { 'event': 'Async', 'changedtick': b:changedtick }
let s:async_timer.id = timer_start(
\ max([50, g:deoplete#auto_refresh_delay]),
\ max([20, g:deoplete#auto_refresh_delay]),
\ function('s:completion_async'), {'repeat': -1})
endfunction
function! deoplete#handler#_async_timer_stop() abort
Expand All @@ -132,7 +135,7 @@ function! s:completion_begin(event) abort
return
endif

if exists('s:prev_completion') && s:prev_completion.event !=# 'Manual'
if g:deoplete#_prev_completion.event !=# 'Manual'
" Call omni completion
for filetype in context.filetypes
for pattern in deoplete#util#convert2list(
Expand Down
16 changes: 15 additions & 1 deletion autoload/deoplete/init.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
" License: MIT license
"=============================================================================

let s:dp_main = fnamemodify(expand('<sfile>'), ':h:h:h')
\ . '/rplugin/python3/deoplete/dp_main.py'

if !exists('s:is_enabled')
let s:is_enabled = 0
endif
Expand Down Expand Up @@ -100,6 +103,11 @@ function! deoplete#init#_disable() abort
endfunction

function! deoplete#init#_variables() abort
let g:deoplete#_prev_completion = {
\ 'complete_position': [],
\ 'candidates': [],
\ 'event': '',
\ }
let g:deoplete#_context = {}
let g:deoplete#_rank = {}
if !exists('g:deoplete#_logging')
Expand Down Expand Up @@ -135,7 +143,7 @@ function! deoplete#init#_variables() abort
call deoplete#util#set_default(
\ 'g:deoplete#auto_complete_delay', 50)
call deoplete#util#set_default(
\ 'g:deoplete#auto_refresh_delay', 500)
\ 'g:deoplete#auto_refresh_delay', 50)
call deoplete#util#set_default(
\ 'g:deoplete#max_abbr_width', 80)
call deoplete#util#set_default(
Expand All @@ -144,6 +152,8 @@ function! deoplete#init#_variables() abort
\ 'g:deoplete#skip_chars', [])
call deoplete#util#set_default(
\ 'g:deoplete#complete_method', 'complete')
call deoplete#util#set_default(
\ 'g:deoplete#max_processes', 4)

call deoplete#util#set_default(
\ 'g:deoplete#keyword_patterns', {})
Expand Down Expand Up @@ -221,6 +231,10 @@ function! deoplete#init#_context(event, sources) abort

return {
\ 'changedtick': b:changedtick,
\ 'serveraddr': (has('nvim') ?
\ v:servername : neovim_rpc#serveraddr()),
\ 'python3': get(g:, 'python3_host_prog', 'python3'),
\ 'dp_main': s:dp_main,
\ 'event': event,
\ 'input': input,
\ 'is_windows': ((has('win32') || has('win64')) ? v:true : v:false),
Expand Down
5 changes: 5 additions & 0 deletions autoload/deoplete/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ function! deoplete#util#rpcnotify(event, context) abort
return ''
endif
call s:notify(a:event, a:context)
if has('nvim') && a:event ==# 'deoplete_on_event' && a:context['event'] ==# 'VimLeavePre'
while !exists('g:deoplete#_process_stopped')
sleep 50m
endwhile
endif
return ''
endfunction

Expand Down
20 changes: 14 additions & 6 deletions doc/deoplete.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ g:deoplete#max_list

Default value: 100

*g:deoplete#max_processes*
g:deoplete#max_processes
The max number of processes used for the asynchronous
completion.
If it is less than equal 1, this feature is disabled.

Default value: 4

*g:deoplete#max_abbr_width*
g:deoplete#max_abbr_width
If the candidate abbr length exceeds the length it will be cut
Expand Down Expand Up @@ -222,7 +230,7 @@ g:deoplete#auto_complete_delay
g:deoplete#auto_refresh_delay
Delay the refresh when asynchronous.

Default value: 500
Default value: 50

*g:deoplete#skip_chars*
g:deoplete#skip_chars
Expand Down Expand Up @@ -1281,9 +1289,9 @@ phpcd.vim: another PHP omnifunc. Faster.
https://github.com/php-vim/phpcd.vim

==============================================================================
FREQUENTLY ASKED QUESTIONS (FAQ) *deoplete-faq*
FREQUENTLY ASKED QUESTIONS (FAQ) *deoplete-faq*

*deoplete-faq-trouble*
*deoplete-faq-trouble*
1. Troubleshooting~

Q: deoplete does not work.
Expand Down Expand Up @@ -1370,7 +1378,7 @@ A: Please enable logging feature like this. >
call deoplete#enable_logging('DEBUG', 'deoplete.log')
call deoplete#custom#source('jedi', 'is_debug_enabled', 1)
<
*deoplete-faq-config*
*deoplete-faq-config*
2. Configuration~

Q: I want to silence the |ins-completion-menu| messages in the command line
Expand Down Expand Up @@ -1515,7 +1523,7 @@ Q: What does each part of a line on the pop up mean? For example I see:
A: It is the source mark. [~] is from around source. A is from
|deoplete-source-around|.

*deoplete-faq-ft-specific*
*deoplete-faq-ft-specific*
3. Filetype Specific Questions~

Q: I want to disable the auto completion for certain filetypes.
Expand Down Expand Up @@ -1579,7 +1587,7 @@ Q: I want to complete AAA using deoplete.

A: You can create the source for it. Why don't create the source if you need?

*deoplete-faq-general*
*deoplete-faq-general*
4. General Questions~

Q: How to donate money to you?
Expand Down
4 changes: 2 additions & 2 deletions rplugin/python3/deoplete/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def init_channel(self, args):
self._deoplete = Deoplete(self._vim)

@neovim.rpc_export('deoplete_enable_logging')
def enable_logging(self):
def enable_logging(self, context):
self._deoplete.enable_logging()

@neovim.rpc_export('deoplete_auto_completion_begin')
Expand All @@ -51,7 +51,7 @@ def on_event(self, context):
def deoplete_init():
pass

def deoplete_enable_logging():
def deoplete_enable_logging(context):
global_deoplete.enable_logging()

def deoplete_auto_completion_begin(context):
Expand Down
Loading

0 comments on commit 0a6debf

Please sign in to comment.