Support no TriggerCharacter

This commit is contained in:
Regen
2020-04-29 19:25:51 +09:00
parent 67aced6544
commit 2d36887b26

View File

@@ -40,17 +40,26 @@ class CMakeLanguageServer(LanguageServer):
self._api = API(cmake, Path(builddir)) self._api = API(cmake, Path(builddir))
self._api.parse_doc() self._api.parse_doc()
@self.feature(COMPLETION, trigger_characters=['{', '(']) trigger_characters = ['{', '(']
@self.feature(COMPLETION, trigger_characters=trigger_characters)
def completions(params: CompletionParams): def completions(params: CompletionParams):
if (hasattr(params, 'context') and params.context.triggerKind == if (hasattr(params, 'context') and params.context.triggerKind ==
CompletionTriggerKind.TriggerCharacter): CompletionTriggerKind.TriggerCharacter):
token = '' token = ''
trigger = params.context.triggerCharacter trigger = params.context.triggerCharacter
else: else:
word = self._cursor_word(params.textDocument.uri, line = self._cursor_line(params.textDocument.uri,
params.position, False) params.position)
token = '' if word is None else word[0] idx = params.position.character - 1
trigger = None if 0 <= idx < len(line) and line[idx] in trigger_characters:
token = ''
trigger = line[idx]
else:
word = self._cursor_word(params.textDocument.uri,
params.position, False)
token = '' if word is None else word[0]
trigger = None
items: List[CompletionItem] = [] items: List[CompletionItem] = []