Sublime Forum

Autocomplete feature requests discussion

#1

A couple of feature requests:

First, I regularly find myself having to cancel the autocomplete dropdown when I’m in a string. It’d be cool for me if the feature didn’t kick in if I was in a string (presumably this can be gleaned from scope). Am I missing something major though that’s useful for others?

I use PHP mainly, and I understand that some people us the variable realisation thing of <?php echo "Hi $name"; ?> and thus it’s useful to have the autocomplete dropdown activating. I don’t personally like that feature (makes the code less readable in my mind), and find myself typing (for example) “pack” and getting “pack(format|)” sometimes by mistake. I understand that autocomplete only completes on tab (depending on settings, see below) but really the annoying thing is that it gets in the way and/or eats my “down arrow” key. I think having a setting could help here. I don’t expect much here as it’s something of an edge case (filling in words in strings after they’ve been made rather than live-while-writing-the-line-of-code, hence needing the down arrow key) but it has happened a lot to me today randomly.

My second feature request associated to autocomplete is the ability to use enter to ‘accept’ an autocomplete in given situations. I understand there’s a setting to make it so you can use enter to accept a completion, but I don’t personally like that. Having said that, if I type something, get the dropdown and then press “down arrow” a few times to get to the third item in the list (for example), it makes sense for me to then press enter rather than tab. The context of “autocomplete is active and the user has interacted with it” could be the factor that turns enter-to-accept temporarily on. Thoughts?

0 Likes

#2

Hello. In the PHP completions file the scope is:

“scope”: “source.php - variable.other.php”,
you could try amending it to

"scope": "source.php - string - variable.other.php", // or possibly "scope": "source.php - string.other.php - variable.other.php", // ??
but you might find it’s more trouble than it’s worth: in PHP an awful lot of coding is done between quotes. However, you should still be able to press Tab or Ctrl-Space to initiate completions.

In my default key bindings it has:

[code]{ “keys”: “enter”], “command”: “commit_completion”, “context”:

	{ "key": "auto_complete_visible" },
	{ "key": "setting.auto_complete_commit_on_tab", "operand": false }    // delete this (and the previous comma)
]

},[/code]
If you copy this to your user key bindings and either delete that last key, or use “operand”: true, it might behave as you prefer.

I wonder if it’s possible for key-bindings to be syntax-specific? Anyway, Andy.

0 Likes

#3

Yes. I believe something like this will work in source.php but not in strings:

"key": "ctrl+blah"], "command": "blah_command",
"context":
    
        { "key": "selector", "operator": "equal", "operand": "source.php", "match_all": true },
        { "key": "selector", "operator": "not_equal", "operand": "string", "match_all": false }
    ]
0 Likes

#4

Cool, atomi - that didn’t occur to me Doh!

Andy.

0 Likes

#5

As I known autocomplete has three stages:

  1. Snipsets
  2. Plugin
  3. Text analizing

And only one event (before part 2.)
on_query_completions

It is interesting for me to:
get snipset comletition
Something like that:

print self.snipsets_autocomplete
>>> ("aa","aa") ]
self.snipsets_autocomplete = ] # remove all snipset autocomplete

get option to turn off text autocomplete from plugin

self.autocomplete_from_text = False
I did not always need this info.
If file has 40 000 lines it take more than second to show autocomplete.

**I want event on autocompete done **
Just to reformat text after.

# before
do_some<cursor>thing
# after
do_somethingthing
# i want to have opportunity to change it to
do_something
0 Likes