我为Sublime Text 2编写插件,我想使用autocomplete feauture。但我无法理解它是如何运作的。在官方API文档中,有一个名为showCompletions(point, prefix, [completions])
的类.View方法,但我有错误: AttributeError:'View'对象没有属性'showCompletions'。有没有关于如何在插件创建中正确使用自动填充方法的示例?
答案 0 :(得分:1)
根据您发布的功能的名称,您可能正在查看ST1文档。这是ST2文档。 http://www.sublimetext.com/docs/2/api_reference.html
话虽如此,文档不完整,并没有描述完成行为。下面是一段代码,用于创建一个插件,用于填充自动完成列表中的条目。返回值包含指定显示文本和插入文本的元组列表。如果您需要进一步说明,请发表评论,但这应该让您开始朝着正确的方向前进。
class EventListener(sublime_plugin.EventListener):
def on_query_completions(self, view, prefix, locations):
return [("Text to display in completion list", "Text to insert")]