atom / snippets

Atom snippets package
MIT License
205 stars 100 forks source link

Allow snippets to have highest priority for autocomplete suggestions #265

Closed zaynv closed 5 years ago

zaynv commented 6 years ago

Prerequisites

Description

For example, when using packages like atom-ide-ui and ide-flowtype the autocomplete suggestions from them usually show on top of the suggestions from my snippets. So when I do something like cl+Tab it autocompletes to something like class instead of my console.log snippet.

Steps to Reproduce

Install some package that also gives you autocomplete suggestions for a language (for example, atom-ide-ui + an ide-* package, and then you can see that their suggestions will show above snippets suggestions.

Expected behavior: Snippets suggestions should always be on top (or make this configurable at least)

Actual behavior: Can't control autocomplete suggestion priority for snippets

Reproduces how often: Not sure, but it happens quite often

Versions

ATOM
============
Atom    : 1.24.0
Electron: 1.6.16
Chrome  : 56.0.2924.87
Node    : 7.4.0

APM
============
apm  1.18.12
npm  3.10.10
node 6.9.5 x64
atom 1.24.0
python 2.7.12
git 2.10.1

OS
============
macOS High Sierra 10.13.3

Please let me know if I can provide any more info.

dead-claudia commented 6 years ago

If this is done, I'd also like an ability to disable this on a per-snippet basis. I currently have a few snippets that overlap with common variable names, and I'd like to be able to do the opposite. (I'd prefer a local func to come before fun, but while still being able to expand via the auto-complete menu.)

savetheclocktower commented 5 years ago

This feels like a band-aid for the larger problem:

  1. Before the autocomplete menu appears, Tab expands a snippet.
  2. After the autocomplete menu appears, Tab selects the active item in the menu.
  3. The menu pops up some number of milliseconds after you stop typing, so Tab is liable to have changed functions in the small amount of time in between deciding to press it and pressing it.

Completion providers can specify a suggestionPriority to the autocomplete-plus package, so the concept of higher- and lower-priority providers exists. If you forked the autocomplete-snippets package, you could change the suggestion priority to a different number to force snippets to come first. But a better solution would be to make all the autocomplete-* packages (which contain the providers) expose their priority on a settings page so that they can be customized by users.

If all you care about is avoiding this single UI annoyance, I’d recommend going into the autocomplete-plus settings and increasing the delay before the autocomplete menu appears, or else prevent it from appearing altogether until invoked manually. Otherwise I think you should broach this topic in the autocomplete-plus repo to see how the maintainers feel about encouraging provider packages to make their inclusion/suggestion priorities configurable.

savetheclocktower commented 5 years ago

Closing this one because it's not within the scope of the snippets package (see above comment).