From a3521de64e8dfc2e8dbfc562fbc73502ba3e09ce Mon Sep 17 00:00:00 2001 From: delphinus Date: Tue, 25 Jun 2019 17:57:38 +0900 Subject: Use input_patterns & add comments for updating it --- autoload/ale/completion.vim | 3 ++- rplugin/python3/deoplete/sources/ale.py | 8 +++++++- test/python/test_deoplete_source.py | 6 +++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim index 284b1e08..f0d6425d 100644 --- a/autoload/ale/completion.vim +++ b/autoload/ale/completion.vim @@ -59,7 +59,8 @@ let s:omni_start_map = { \ '': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$', \} -" A map of exact characters for triggering LSP completions. +" A map of exact characters for triggering LSP completions. Do not forget to +" update self.input_patterns in ale.py in updating entries in this map. let s:trigger_character_map = { \ '': ['.'], \ 'typescript': ['.', '''', '"'], diff --git a/rplugin/python3/deoplete/sources/ale.py b/rplugin/python3/deoplete/sources/ale.py index 653bc4fc..66a09551 100644 --- a/rplugin/python3/deoplete/sources/ale.py +++ b/rplugin/python3/deoplete/sources/ale.py @@ -24,7 +24,13 @@ class Source(Base): self.rank = 1000 self.is_bytepos = True self.min_pattern_length = 1 - self.input_pattern = r'(\.|::|->)\w*$' + # 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*$', + } # Returns an integer for the start position, as with omnifunc. def get_complete_position(self, context): diff --git a/test/python/test_deoplete_source.py b/test/python/test_deoplete_source.py index d219eef1..280df2e3 100644 --- a/test/python/test_deoplete_source.py +++ b/test/python/test_deoplete_source.py @@ -41,7 +41,11 @@ class DeopleteSourceTest(unittest.TestCase): ) self.assertEqual(attributes, { - 'input_pattern': r'(\.|::|->)\w*$', + 'input_patterns': { + '_': r'\.\w*$', + 'rust': r'(\.|::)\w*$', + 'typescript': r'(\.|\'|")\w*$', + }, 'is_bytepos': True, 'mark': '[L]', 'min_pattern_length': 1, -- cgit v1.2.3