summaryrefslogtreecommitdiff
path: root/rplugin
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-04-23 21:26:16 +0100
committerw0rp <devw0rp@gmail.com>2019-04-23 21:26:25 +0100
commit01331266a84859d4b0935b81ae773ff0d7af7522 (patch)
treea3ea9871165efc259acd01d849d684bf3f1428de /rplugin
parentce0b14979ea7429f07b6ca496333f72d93a8d013 (diff)
downloadale-01331266a84859d4b0935b81ae773ff0d7af7522.zip
Close #1753 - Implement minimum viable integration with Deoplete
Diffstat (limited to 'rplugin')
-rw-r--r--rplugin/python3/deoplete/sources/ale.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/rplugin/python3/deoplete/sources/ale.py b/rplugin/python3/deoplete/sources/ale.py
new file mode 100644
index 00000000..1addfae3
--- /dev/null
+++ b/rplugin/python3/deoplete/sources/ale.py
@@ -0,0 +1,50 @@
+"""
+A Deoplete source for ALE completion via tsserver and LSP.
+"""
+__author__ = 'Joao Paulo, w0rp'
+
+try:
+ from deoplete.source.base import Base
+except ImportError:
+ # Mock the Base class if deoplete isn't available, as mock isn't available
+ # in the Docker image.
+ class Base(object):
+ def __init__(self, vim):
+ pass
+
+
+# Make sure this code is valid in Python 2, used for running unit tests.
+class Source(Base):
+
+ def __init__(self, vim):
+ super(Source, self).__init__(vim)
+
+ self.name = 'ale'
+ self.mark = '[L]'
+ self.rank = 100
+ self.is_bytepos = True
+ self.min_pattern_length = 1
+
+ # Returns an integer for the start position, as with omnifunc.
+ def get_completion_position(self):
+ return self.vim.call('ale#completion#GetCompletionPosition')
+
+ def gather_candidates(self, context):
+ if context.get('is_refresh'):
+ context['is_async'] = False
+
+ if context['is_async']:
+ # Result is the same as for omnifunc, or None.
+ result = self.vim.call('ale#completion#GetCompletionResult')
+
+ 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')
+
+ return []