New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom filters for suggestions #635

Closed
rm-code opened this Issue Dec 6, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@rm-code

rm-code commented Dec 6, 2015

The issue

I am currently writing my own provider, which should provide snippets and autocomplete functionality for functions of the LÖVE framework. The problem is, that autocomplete-plus uses the snippet field for filtering when filterSuggestions is set to true (at least as far as I can tell).

For example it wouldn't work for a suggestion like this:

  {
    "displayText": "love.directorydropped",
    "type": "function",
    "description": "Callback function triggered when a directory is dragged and dropped onto the window.",
    "descriptionMoreURL": "https://love2d.org/wiki/love.directorydropped",
    "snippet": "function love.directorydropped(${1:path (string)})\n    ${2:body (lua)}\nend\n"
  }

I'd like to type ldir and have the suggestion for love.directorydropped at the top of the autocomplete list, but since autocomplete-plus tries to match ldir to the snippet (which starts with function ... nothing is suggested at all.

This also means you can't use snippets which start with a variable:
${0:Source}:isPaused()

Suggestion

Of course this might just be a special case which rarely comes up, but maybe it might make sense to allow creators of new providers to specify a filter field which is matched against the prefix.

  {
    "displayText": "love.directorydropped",
    "type": "function",
    "description": "Callback function triggered when a directory is dragged and dropped onto the window.",
    "descriptionMoreURL": "https://love2d.org/wiki/love.directorydropped",
    "filter": "love.directorydropped",
    "snippet": "function love.directorydropped(${1:path (string)})\n    ${2:body (lua)}\nend\n"
  }

autocomplete-plus could still fall back to the default behaviour, if the filter field isn't provided.

@lee-dohm lee-dohm added the question label Dec 6, 2015

@lee-dohm lee-dohm changed the title from [Question] Filtering the suggestions to Filtering the suggestions Dec 6, 2015

rm-code added a commit to rm-code/love-atom that referenced this issue Dec 9, 2015

Change json-generator to create shorter snippets
This is needed to make the provider work correctly with the fuzzy filter
of autocomplete-plus.

See: atom/autocomplete-plus#635

@lee-dohm lee-dohm added enhancement and removed question labels Dec 9, 2015

@rm-code

This comment has been minimized.

Show comment
Hide comment
@rm-code

rm-code Jan 22, 2016

Updated the description with another case where this behavior causes troubles.

rm-code commented Jan 22, 2016

Updated the description with another case where this behavior causes troubles.

@rm-code rm-code changed the title from Filtering the suggestions to Custom filters for suggestions Jan 22, 2016

@rm-code

This comment has been minimized.

Show comment
Hide comment
@rm-code

rm-code Mar 26, 2017

This seems to have been added / fixed by now.

rm-code commented Mar 26, 2017

This seems to have been added / fixed by now.

@rm-code rm-code closed this Mar 26, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment