Micro: Snippets

Created on 21 Jun 2016  路  9Comments  路  Source: zyedidia/micro

It would be nice to support snippets. The user would type a predefined pattern (defined for the current filetype), press a key, and it would expand into a large piece of code. This is meant for dealing with boilerplate. Here is an example of a Vim snippets plugin:

snippets

We can just use their predefined patterns from this repository.

Ref #174

enhancement

Most helpful comment

@zyedidia if you are not working on this I would start implementing it...

All 9 comments

@zyedidia if you are not working on this I would start implementing it...

Sure. I recommend implementing it as a plugin because that feels more natural to me. I understand that the plugin system isn't so mature yet, so if you have any issues let me know.

What do you think of implementing it as a plugin vs in the core?

I think implementing it as plugin seems like a good idea but it might require some additions to core which could also benefit other plugins.

If you have a look at the screenshot you've postet there is some kind of dropdrown which I would implement in the core which then might get populated by different plugins. which could also be used for various autocomplete plugins (which make also more sense as plugin...)

Yeah, I think the behavior from the screenshot is much more advanced than necessary. The dropdown menu is from Vim's autocompletion and the variable completion is not really necessary.

progress can be seen on my snippet branch

Hi again, I'm making some good progress though I'm not sure if the current way of input handling is the right choice. @zyedidia would you mind to have a look and tell me what you're thinking before I continue?

I'm not sure what you mean by "input handling" but I think it looks good. Just one note: the extension for snippets files should be .snippets not .snippet.

Great progress 馃憤 .

With "Input handling" I mean the last 2 changes with onBeforeTextEvent etc.
And I have some problem with selecting the next placeholder. But I guess thats nothing impossible :)

This is now finished thanks to @boombuler! You can install the snippets plugin using the new plugin manager with plugin install snippets.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xintrea picture xintrea  路  3Comments

handicraftsman picture handicraftsman  路  4Comments

zanglebert picture zanglebert  路  4Comments

luis-lavaire picture luis-lavaire  路  3Comments

utkarsh2102 picture utkarsh2102  路  3Comments