summaryrefslogtreecommitdiff
path: root/rplugin
diff options
context:
space:
mode:
authorJerko Steiner <jerko.steiner@gmail.com>2020-01-01 20:00:41 +0100
committerw0rp <w0rp@users.noreply.github.com>2020-01-01 19:00:41 +0000
commit0cb432cb825e80c5a6f6dc9bc9c52a38f9b45319 (patch)
tree6b9f0935d141e7fa8adce7499ad7868b24101220 /rplugin
parent874c98b96d913299fd61b3125211d299b012572c (diff)
downloadale-0cb432cb825e80c5a6f6dc9bc9c52a38f9b45319.zip
Add TypeScript autoimport support for deoplete (#2779)
* Add autoimport support for deoplete * Fix test_deoplete_source.py * Use callback instead of is_async for deoplete Shuogo, the author of Deoplete, does not recommend using the `is_async` option: > I think is_async is not recommended. It is not so useful and broken. > You should use callback system instead. Link: https://github.com/Shougo/deoplete.nvim/issues/1006#issuecomment-526797857 Incidentally, the same thread mentiones an issue started by w0rp: https://github.com/Shougo/deoplete.nvim/issues/976 The deoplete docs also say is_async is deprecated: > is_async (Bool) > If the gather is asynchronous, the source must set > it to "True". A typical strategy for an asynchronous > gather_candidates method to use this flag is to > set is_async flag to True while results are being > produced in the background (optionally, returning them > as they become ready). Once background processing > has completed, is_async flag should be set to False > indicating that this is the last portion of the > candidates. > > Note: The feature is deprecated and not recommended. > You should use callback system by > |deoplete#auto_complete()| instead. Link: https://github.com/Shougo/deoplete.nvim/blob/master/doc/deoplete.txt Co-authored-by: w0rp <w0rp@users.noreply.github.com>
Diffstat (limited to 'rplugin')
-rw-r--r--rplugin/python3/deoplete/sources/ale.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/rplugin/python3/deoplete/sources/ale.py b/rplugin/python3/deoplete/sources/ale.py
index 3955ed2d..ae1f4039 100644
--- a/rplugin/python3/deoplete/sources/ale.py
+++ b/rplugin/python3/deoplete/sources/ale.py
@@ -24,6 +24,7 @@ class Source(Base):
self.rank = 1000
self.is_bytepos = True
self.min_pattern_length = 1
+ self.is_volatile = True
# Do not forget to update s:trigger_character_map in completion.vim in
# updating entries in this map.
self.input_patterns = {
@@ -44,21 +45,16 @@ class Source(Base):
if not self.vim.call('ale#completion#CanProvideCompletions'):
return None
- if context.get('is_refresh'):
- context['is_async'] = False
+ event = context.get('event')
- if context['is_async']:
- # Result is the same as for omnifunc, or None.
+ if event == 'Async':
result = self.vim.call('ale#completion#GetCompletionResult')
+ return result or []
- if result is not None:
- context['is_async'] = False
-
- return result
- else:
- context['is_async'] = True
-
- # Request some completion results.
- self.vim.call('ale#completion#GetCompletions', 'deoplete')
+ if context.get('is_refresh'):
+ self.vim.command(
+ "call ale#completion#GetCompletions('ale-callback', " + \
+ "{'callback': {completions -> deoplete#auto_complete() }})"
+ )
return []