Skip to content
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

Snippets #349

Closed
wants to merge 22 commits into from
Closed

Snippets #349

wants to merge 22 commits into from

Conversation

boombuler
Copy link
Contributor

I think I finally reached a state where the plugin is usable. (fix for #175)

What is currently missing:

  • It's not yet added to the runtime.go
  • some kind of keybinding might be nice but I leave that to you
  • Some more testing might also be a good idea...

@zyedidia
Copy link
Owner

Wow! This looks really good and you did it so fast too. Very nice!

I have been testing it with the go.snippets and I have just a couple remarks:

For very simple snippets like

snippet bl
    bool

the cursor is moved to the start of the word after the snippet is inserted but it should be moved to the end.

For snippets like

snippet v
    ${1} := ${2}

where the cursor locations have to placeholders, an empty selection is created which isn't necessary and causes problems when at the end of the line with ${2} because it selects the newline, which then gets deleted.

Those are the only problems I found. Now comes the question of what should the keybindings be, and where should the snippets be stored.

@boombuler
Copy link
Contributor Author

I will have a look at those two issues might take a day or two...
About the keybindings: Not sure how its handled but wouldn't it be possible to bind both to tab? And proceed to the next binding if nothing matched?

About the question where those snippets might get stored: Some kind of package management for plugins might be helpful. Including all packages and snippets within the binary might increase the file size more then needed for most users...

* inserting snippets without a placeholder locates the cursor at the end of the snippet
* fixed bug with selecting empty placeholders
* added more commands
@boombuler
Copy link
Contributor Author

ok the bugs you've mentioned should be fixed.
I've also reindented the script, added some more commands and did some minor cleanup.

@handicraftsman
Copy link
Contributor

o_O

@handicraftsman
Copy link
Contributor

MB, i'll add syntax-highlighting for snippet files

@zyedidia
Copy link
Owner

zyedidia commented Sep 16, 2016

I changed the way plugin help files works in the last commit so the help.md help file needs to be changed. You should rename it to something like snippets.md and move it to a help directory if you'd like.

Then you can register it in the lua code with

AddRuntimeFile("snippets", "help", "help/snippets.md")

Also I'm not sure if this plugin should be provided by default with all the snippets. Perhaps this should be the first third-party plugin? If that's the case then we need to add some sort of plugin manager.

@zyedidia
Copy link
Owner

The new runtime file organization from your latest PR also means that other plugins can add their own snippets files with AddRuntimeFile("pluginName", "snippets", "filetype.snippets") even if "snippets" is not a filetype recognized by the core. I think it would be best if this plugin read snippet files using ListRuntimeFiles("snippets").

@boombuler
Copy link
Contributor Author

Hi,

I've merged the master branch to keep this up to date and the plugin now reads the snippets from the runtime files as you said. (type snippets). The help is also provided via runtime files and I fixed a potential bug on windows systems. (Hint: if you concat file paths use the join function from the path/filepath go-package since it handles the system specific directory delimiter.

@boombuler
Copy link
Contributor Author

Some kind of plugin manager would be great, since it would keep the binary small.
I think its even easier to provide since the runtime file PR. since the mentioned manifest file could be replaced by some AddRuntimeFile calls from the script.
If the core would provide some HTTP-Api for the plugins, it would be even possible to implement the plugin manager as a plugin. (Maybe the plugin-scripts should be handled by the runtime files too, that way the core-plugins could be updated without updating the editor)

@boombuler boombuler mentioned this pull request Sep 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants