]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/rplugin/python3/deoplete/sources/ale.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / rplugin / python3 / deoplete / sources / ale.py
diff --git a/.vim/bundle/ale/rplugin/python3/deoplete/sources/ale.py b/.vim/bundle/ale/rplugin/python3/deoplete/sources/ale.py
new file mode 100644 (file)
index 0000000..a692dc3
--- /dev/null
@@ -0,0 +1,62 @@
+"""
+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 = 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 = {
+            '_': r'\.\w*$',
+            'rust': r'(\.|::)\w*$',
+            'typescript': r'(\.|\'|")\w*$',
+            'cpp': r'(\.|::|->)\w*$',
+            'c': r'(\.|->)\w*$',
+        }
+
+    # Returns an integer for the start position, as with omnifunc.
+    def get_complete_position(self, context):
+        return self.vim.call(
+            'ale#completion#GetCompletionPositionForDeoplete', context['input']
+        )
+
+    def gather_candidates(self, context):
+        # Stop early if ALE can't provide completion data for this buffer.
+        if not self.vim.call('ale#completion#CanProvideCompletions'):
+            return None
+
+        event = context.get('event')
+
+        if event == 'Async':
+            result = self.vim.call('ale#completion#GetCompletionResult')
+
+            return result or []
+
+        if context.get('is_refresh'):
+            self.vim.command(
+                "call ale#completion#GetCompletions('ale-callback', "
+                + "{'callback': {completions -> deoplete#auto_complete() }})"
+            )
+
+        return []