def on_query_completions(self, view, prefix, locations):
# parts of the code inspired by: https://github.com/agibsonsw/AndyPython/blob/master/PythonCompletions.py
global builtin_compl_vars, builtin_compl_funcs, magic_control_pars
if not view.match_selector(locations[0], 'source.ksp -string -comment -constant'):
return []
pt = locations[0] # - len(prefix) - 1
#ch = view.substr(sublime.Region(pt, pt + 1)) # the character before the trigger
line_start_pos = view.line(sublime.Region(pt, pt)).begin()
line = view.substr(sublime.Region(line_start_pos, pt)) # the character before the trigger
if re.match(r' *declare .*', line) and ':=' not in line:
compl = []
elif re.match(r'.*-> ?[a-zA-Z_]*$', line): # if the line ends with something like '->' or '->valu'
compl = magic_control_pars
else:
compl = self._extract_completions(view, prefix, pt)
compl = [(item + "\tdefault", item) for item in compl
if len(item) > 3 and item not in all_builtins]
if '.' not in prefix:
bc = []
bc.extend(builtin_compl_vars)
bc.extend(builtin_compl_funcs)
compl.extend(bc)
compl = self.unique(compl)
return (compl, sublime.INHIBIT_WORD_COMPLETIONS |
sublime.INHIBIT_EXPLICIT_COMPLETIONS)
评论列表
文章目录