Sublime Forum

Auto-Completion keys

#1

I’d like to assign one key to commit autocomplete.

The options seem rather limited…
auto_complete_commit_on_tab": false

Missing:
"auto_complete_commit_on_enter": false
"auto_complete_commit_on_space": false

This command auto_complete_triggers seems to apply to opening auto-complete,
"auto_complete_triggers": [ { "characters": "<", "selector": "text.html" } ]

Auto-Complete should trigger (open) when typed text could be completed.
Auto-Complete list should initially only respond to user defined key, I want to use /
So, with the list open, if I hit arrow down or enter or tab, auto-complete will go away.
Press / to focus list, then and only then should arrows and enter and tab have any affect.

Should not respond to any input until focused.
For example,

  1. Type in Auto_
  2. Auto_complete list opens with…
    auto_complete
    auto_match_enabled
  3. Press / to focus on the list == Auto-Complete Mode
  4. Select from list
  5. Enter to auto complete.

Once in Auto-Complete Mode, I would set…
Complete = Enter or /
Next item = Down Space Dot
Prev item = Up Comma
First item = Home
Last item = End
A-Z = Append to keyword and update list
Backspace = Remove char from keyword.

The auto-complete lists shows several options,

0 Likes

#2

So I added this post to the first one.
Better to edit post in a real editor to avoid posting before it’s done.

I found this,

	pos = view_sel[0].end()
	next_char = view.substr(sublime.Region(pos - 1, pos))

	if next_char in (' ', '\n'):
		view.run_command('hide_auto_complete')
		return

But I’m not sure where to put it or what else might be needed.

0 Likes

#3

You should check the default keybindings file, if you haven’t already.

0 Likes

#4

Standard keymaps are not going to do it.

Needed:

  1. Key for auto_complete_focus
  2. Multiple commands processed in keymaps.

While completion displayed, not focused, Enter closes the completion and inserts a new line.
While completion displayed, and focused, Enter commits the selected completion item.

0 Likes

#5

Ah, I see, you want a separate “autocomplete is now focused” mode. You can implement that with a context using the setting.<setting_name> key, after you set that setting of the view to true using view.settings().set('<setting_name>', True) inside a plugin command. And you need a way to remove the setting when the popup closes, which is the more complicated part about this and may end up looking like this.

Other than that, you only need key bindings that you can mostly infer from the default bindings, assuming mapping ,. to the same keys as the up-down arrows works for the autocompletion popup.

0 Likes

#6

Thanks, I’ll see what I can do with this.

0 Likes

#7

Can someone help me implement this ?

0 Likes