-
Notifications
You must be signed in to change notification settings - Fork 1
Home
When you want to extend the RehQ plugin further by adding more snippets, a few things should be regarded:
- The filename should contain the snippets purpose and trigger and has to end with .sublime-snippet (see the naming section for further reference)
- The snippets should be located in the (top level) Snippets folder
- The snippets should be well formed, to be discovered by the Show available snippets command (see the attributes section
Snippets in Sublime Text (ST) are stored as xml documents. All snippets therefore have to be valid xml.
For further information on Snippets in ST you may refer to this blog post (or just google “sublime text snippets” :-)
In general, all files with the ending .sublime-snippet (and in unit tests also .sublime-snippet.test) will be discovered by Sublime Text automatically (disregard their location within the RehQ package). So as long as the snippet is valid xml and matches the Sublime Text (ST) snippet standard, the snippet will be available immediately (without needing to restart ST).
As for the Show available snippets tooltip, the snippet discovery is limited to the (top level) Snippets folder. Also, the snippets have to be well formed with regards to some additional requirements, in order to appear in the list properly.
ST offers a command which opens a new file with the relevant snippet scaffold (located under Tools > Developer > New Snippet…). You could then created your snippet and add the required attributes yourself.
The final snippet has to be saved in your local RehQ Snippets folder (make sure to follow the RehQ naming conventions when saving your snippet).
You can find the RehQ package location through ST (Preference > Browse Packages…).
As an alternative, you can also just duplicate any of the existing Snippets in that location and just use the existing snippet as a starting point.
RehQ needs the following attributes to format the Snippet list correctly:
Required Attribute | Used as |
---|---|
title | heading in the available snippets overview |
hint | description in the available snippets overview |
tabTrigger | shorthand to type in sublime, which is used for the tab completion |
scope | limiter, to limit snippets to function in documents with the set scope (should always be `text.html.textile`) |
description | description in case that multiple snippets are available under the same trigger |
(You may have a look at an existing snippet to help you get started and to better understand the table.)
In order to test if your final snippets satisfies these formal requirements, there also is a command available `RehQ > Development > Test snippets are all well formed`.
The command will then check all the snippets in the Snippets folder for the presence of the aforementioned attributes.
Note: In order for the command to check your custom snippets, you would have to put them in your local RehQ-Snippets folder first, before adding them to the repository!
The following naming convention was introduced when adding snippets and it should be followed. Snippets name should have a description and the trigger included in the filename. Multiple words may be separated by underscores. The description and the trigger are separated by a “-” (hyphen char). A name would then look as follows useful_snippet-usfl.sublime-snippet, where useful_snippet is the description and usfl the trigger to type.