Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

[Feature request] A service to add/remove/read snippets programmatically #190

Open
dead-claudia opened this issue Jan 28, 2016 · 1 comment

Comments

@dead-claudia
Copy link

Summary

What I'm proposing is a new provided service to manipulate snippets programmatically. Such a service would have to do the following:

  • Emit an event when the existing snippets before the service are loaded (the existing facility just needs exported through the service).
  • Add snippets, with all the normal options, a name, and a scope selector.
  • Remove snippets, with all the normal options, a name, and a scope selector.
  • Read snippets with a selector argument and prefix, returning its name and a deep clone of its options.

Use cases

Macro system

I want to implement a very powerful macro system for Atom on top of this package, to make it feel native. That's a feature that I know is in high demand. I also want to provide an eady way to manage existing macros, but the other facilities I need for that already exist.

This will require the following:

  • Adding new snippets to act as macros.
  • Looking up existing snippets by prefix to save old state instead of overriding them permanently.
  • Removing formerly added ones.

Intelligent autocomplete

This could be used to build a more powerful autocomplete, where someone could make snippets based on the type, or snippets that are only active in certain contexts. One example of this would be defining geti -> getElementById JavaScript snippet only when the parent is document, but not existing elsewhere since it's usually irrelevant in those places.

Also, Atom TypeScript could use this to do Eclipse-like autocomplete, where if you might autocomplete a function, it instead generates an anonymous snippet for that item, and inserts that with the correct arguments, denoting types as well, much like what an IDE would.

declare function func(buffer: Buffer, name: string): void;

func // <tab>
func(buffer, name) // filled in variable names, `buffer` is currently highlighted

This will require the following:

  • Adding new snippets for parameterized autocomplete.
  • Reading existing snippets by prefix to copy and temporarily override them.
  • Removing formerly added ones, as they're only necessary when initializing autocomplete.

This is technically a partial duplicate of #100 and #181, but much more detailed and complete than either. It would also offer an indirect fix for #109, #107, #155, and probably others, and it is related to #33.

@dead-claudia
Copy link
Author

On a tangentally related side note, I hate GitHub outages (this would've been filed two hours ago if that didn't happen right as I was about to submit...thank God for copy+paste).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants