[英]How to create an autocomplete list in Sublime Text for common Python lines?
[英]How to remove words in the current buffer from Sublime Text 4 autocomplete list
在過去 8 年左右的時間里,這個插件與 Sublime Text 2 和 3 配合得很好,可以從ctrl
+ space
自動完成列表中刪除當前緩沖區中的單詞,但它不再適用於 ST4 (b4126):
import sublime, sublime_plugin
class MyAutocomplete(sublime_plugin.EventListener):
def on_query_completions(self, view, prefix, locations):
# Popup autocomplete only for .sublime-snippet and
# .sublime-completions files
return ([], sublime.INHIBIT_WORD_COMPLETIONS)
我知道on_query_completions
和sublime.INHIBIT_WORD_COMPLETIONS
仍然有效,所以我認為問題出在數組返回語句上。 文檔沒有顯示版本之間的任何更改。
我能夠使用sublime.INHIBIT_WORD_COMPLETIONS
的 return 語句的唯一變體是這個,但現在我在列表中多了一個我不想要的補全:
return [
sublime.CompletionItem(
trigger="fox",
completion="The quick brown fox jumps over the lazy dog",
kind=sublime.KIND_KEYWORD
)
], sublime.INHIBIT_WORD_COMPLETIONS
對sublime.CompletionList
或set_completions
運氣都沒有
似乎不可能在不返回至少一個完成的情況下禁止緩沖區/單詞完成。 但是,如果該完成(觸發器和結果)是單個字符,它將永遠不會相關,因此永遠不會顯示自動完成。
import sublime, sublime_plugin
class InhibitWordCompletionsEventListener(sublime_plugin.EventListener):
def on_query_completions(self, view, prefix, locations):
clist = sublime.CompletionList()
sublime.set_timeout(lambda: clist.set_completions([' '], sublime.INHIBIT_WORD_COMPLETIONS), 0)
return clist
(注意:部分基於對https://github.com/sublimehq/sublime_text/issues/4999的評論,我在搜索是否報告了此錯誤時發現了該評論。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.