]> git.madduck.net Git - etc/vim.git/blob - .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
1 """
2 A Deoplete source for ALE completion via tsserver and LSP.
3 """
4 __author__ = 'Joao Paulo, w0rp'
5
6 try:
7     from deoplete.source.base import Base
8 except ImportError:
9     # Mock the Base class if deoplete isn't available, as mock isn't available
10     # in the Docker image.
11     class Base(object):
12         def __init__(self, vim):
13             pass
14
15
16 # Make sure this code is valid in Python 2, used for running unit tests.
17 class Source(Base):
18
19     def __init__(self, vim):
20         super(Source, self).__init__(vim)
21
22         self.name = 'ale'
23         self.mark = '[L]'
24         self.rank = 1000
25         self.is_bytepos = True
26         self.min_pattern_length = 1
27         self.is_volatile = True
28         # Do not forget to update s:trigger_character_map in completion.vim in
29         # updating entries in this map.
30         self.input_patterns = {
31             '_': r'\.\w*$',
32             'rust': r'(\.|::)\w*$',
33             'typescript': r'(\.|\'|")\w*$',
34             'cpp': r'(\.|::|->)\w*$',
35             'c': r'(\.|->)\w*$',
36         }
37
38     # Returns an integer for the start position, as with omnifunc.
39     def get_complete_position(self, context):
40         return self.vim.call(
41             'ale#completion#GetCompletionPositionForDeoplete', context['input']
42         )
43
44     def gather_candidates(self, context):
45         # Stop early if ALE can't provide completion data for this buffer.
46         if not self.vim.call('ale#completion#CanProvideCompletions'):
47             return None
48
49         event = context.get('event')
50
51         if event == 'Async':
52             result = self.vim.call('ale#completion#GetCompletionResult')
53
54             return result or []
55
56         if context.get('is_refresh'):
57             self.vim.command(
58                 "call ale#completion#GetCompletions('ale-callback', "
59                 + "{'callback': {completions -> deoplete#auto_complete() }})"
60             )
61
62         return []