I managed to create this plugin:
import sublime
import sublime_plugin
class OpenAutoCompletionCommand(sublime_plugin.TextCommand):
def run(self, edit, **kargs):
# print( "kargs: ", str( kargs ) )
view = self.view
view.run_command("insert", {"characters": kargs["keystroke"]})
window = view.window()
window.run_command("auto_complete")
Which needs this keymap file Default.sublime-keymap
:
[
{ "keys": ["a"], "command": "open_auto_completion", "args": {"keystroke": "a" } },
{ "keys": ["b"], "command": "open_auto_completion", "args": {"keystroke": "b" } },
{ "keys": ["c"], "command": "open_auto_completion", "args": {"keystroke": "c" } },
{ "keys": ["d"], "command": "open_auto_completion", "args": {"keystroke": "d" } },
{ "keys": ["e"], "command": "open_auto_completion", "args": {"keystroke": "e" } },
{ "keys": ["f"], "command": "open_auto_completion", "args": {"keystroke": "f" } },
{ "keys": ["g"], "command": "open_auto_completion", "args": {"keystroke": "g" } },
{ "keys": ["h"], "command": "open_auto_completion", "args": {"keystroke": "h" } },
{ "keys": ["i"], "command": "open_auto_completion", "args": {"keystroke": "i" } },
{ "keys": ["j"], "command": "open_auto_completion", "args": {"keystroke": "j" } },
{ "keys": ["k"], "command": "open_auto_completion", "args": {"keystroke": "k" } },
{ "keys": ["l"], "command": "open_auto_completion", "args": {"keystroke": "l" } },
{ "keys": ["m"], "command": "open_auto_completion", "args": {"keystroke": "m" } },
{ "keys": ["n"], "command": "open_auto_completion", "args": {"keystroke": "n" } },
{ "keys": ["o"], "command": "open_auto_completion", "args": {"keystroke": "o" } },
{ "keys": ["p"], "command": "open_auto_completion", "args": {"keystroke": "p" } },
{ "keys": ["q"], "command": "open_auto_completion", "args": {"keystroke": "q" } },
{ "keys": ["r"], "command": "open_auto_completion", "args": {"keystroke": "r" } },
{ "keys": ["s"], "command": "open_auto_completion", "args": {"keystroke": "s" } },
{ "keys": ["t"], "command": "open_auto_completion", "args": {"keystroke": "t" } },
{ "keys": ["u"], "command": "open_auto_completion", "args": {"keystroke": "u" } },
{ "keys": ["v"], "command": "open_auto_completion", "args": {"keystroke": "v" } },
{ "keys": ["w"], "command": "open_auto_completion", "args": {"keystroke": "w" } },
{ "keys": ["x"], "command": "open_auto_completion", "args": {"keystroke": "x" } },
{ "keys": ["y"], "command": "open_auto_completion", "args": {"keystroke": "y" } },
{ "keys": ["z"], "command": "open_auto_completion", "args": {"keystroke": "z" } },
]
However, Sublime text is inserting the completion automatically when there is only one option. How to turn this off?
Related threads:
-
#13532 How to get typed key name?
-
#1697 [BUG] Autocompletion doesn’t open the popup
-
#25465 Tab trigger select first one from auto complete popup instead of triggering Emmet completion