[SOLVED] Autocomplete listing order control


#1

How does one control the order of items in the autocomplete list.
In my case in Python, I have a snippet of my preferred shebang line and encoding line.
I trigger it with typing py
However, the completion property ALWAYS comes first, and yet, I cannot think of when I have or will ever use that one… I haven’t figured out the right terms to find what I need to modify to control this.
I want my shebang to appear first when I type py in a Python context.


#2

Autocomplete providers can set their own priorities, but there’s no way for the user to affect it without editing the provider (autocomplete-snippets, in this case), as far as I know. Since this isn’t more than an annoyance (you know what py means, and pressing tab on a snippet prefix overrides whatever autocompletion is suggested), I don’t know if the effort to fix the display would be worthwhile. That said, it is a little weird that autocomplete-snippets doesn’t have a higher priority. Snippets overriding the top suggestion is a little counterintuitive.


#3

Hi.

autocomplete-plus has a few settings to play with.
Would the below setting be of help?

To me what is required is a stricter search. In other words, the autocomplete phrase starts with what was typed. The fuzzy search result of property seems wrong. I would expect at least the letters being consecutive.

- Dan Padric


#4

That’s only for the built-in provider (which indexes the files you have open and suggests things based on what you’ve previously typed).


#5

It has something to do with how the fuzzy search works for the functionality. Any idea where to go and look for ‘tuning’ the functionality?

Thank you for your efforts.


#6

Yeah. It means that, when using the built-in provider, int will prompt it to suggest interest, but not vintage.

Any idea where to go and look for ‘tuning’ the functionality?

What is your goal?


#7

I was wondering how the algorithm of the so called fuzzy search works.

Being a little more strict. ‘property’ would come up when using ‘pr’ (very strict) or even ‘pe’ (more relaxed) but not ‘py’. But that means the search algorithm needs some adjustment. Which package would one need to look at for this case?


#8

Autocomplete packages do what they want. In this case, autocomplete-python is the one making the choice about what to display.


#9

I think it would make sense for the snippet to have top priority.
It is an exact match.
Nothing else is typed in a new, unsaved file, not in a project.

It is absolutely something wrong with the weight of the Fuzzy Search.
Even adjusting the Suggestion Priority has no effect on this example, but turning off Fuzzy Search does.
(But disabling fuzzy search ruins the experience in almost every other situation such as function parameters)

Where would we dive in to tweak autocomplete-python and even submit a merge request.
It does describe its Fuzzy Matcher like this:

Typing stdr will match stderr. First character should always match. Uses additional caching thus completions should be faster. Note that this setting does not affect built-in autocomplete-plus provider.

That indicates that autocomplete-python may not be making the choice?
I’m new at Atom’s packages but well familiar with Python and Cocoa.

I can understand fuzzy search. It’s generally a weighted trie stemmer.
In this case it is definitely adding ridiculous weight to that one built-in function.
(which is really a Python decorator that makes a callable method act and be callable and settable as if it were an attribute, letting you focus on writing a little boilerplate. I rarely use it.)


#10

So this actually worked, in a somewhat surprising way, by making the scope selector more specific by applying to multiple scopes.

Originally I had

    '.source.python':
      #
      'Python shebangs.':
        'prefix': 'py'
        'body': """
        #!/usr/bin/env python
        # -*- coding: utf-8 -*-
        $0
        """

Which seemed intuitive and fine.
However, in true web clunkiness, this works like CSS.
Changing to this now gives me the the effect I wanted.
So adding a broader scope to the overall scope of the snippet pumped it up to in the completion list.

'text.plain.null-grammar, .source.python':
  #
  'Python shebangs.':
    'prefix': 'py'
    'body': """
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    $0
    """

#11

Because when you turn off the fuzzy search on autocomplete-python, py will never match property. It’s not coming up in that case because it’s not even in the list.

I also noticed that the Suggestion Priority setting didn’t change the order of the autocomplete items, but then I reloaded Atom and now it looks completely different.

That indicates that autocomplete-python may not be making the choice?

autocomplete-python is choosing to show property because of its fuzzy search. It’s then sending the list of suggestions to autocomplete-plus, which is organizing them according to suggestion priority, and what looks like a set of opinions based on the type of suggestion (I’m not sure what the rules are).


#12

Oh yes, I did try disabling it, but it certainly was a lot less useful without fuzzy matching.
As I learn about the workings of Atom packages, I’ll hack on it.


#13

Just tweak Suggestion Priority and reload Atom. There might also be warrant for a pull request to tweak autocomplete-snippets so that it exposes its suggestionPriority variable to being changed by a config setting, like autocomplete-python does.


#14

Can you give us a simple rundown on how to do this, or a link to a resource explaining it?


#15

What, like the link I posted in the first comment?


#16

Yep thanks, missed that