-
Notifications
You must be signed in to change notification settings - Fork 6
Home
Your plugin can add by several ways suggestions.
CompletePlus uses amplify.js to get suggestion of other plugins.
-
amplify.publish("Complete.Init");
- called after loading of CompletePlus -
amplify.publish("Complete.Normal", publishObj);
and -
amplify.publish("Complete.Major", publishObj);
both called every time CompletePlus gets called or suggestions get updated -
amplify.publish( "Complete.Session", publishObj);
- called each time complete dialog gets visible -
publishObj contains:
-
the current prefix
-
the current syntax of the file
-
the content before the cursor
-
the text of the current line
-
the current token
-
the current position of the cursor
-
the current file
{"prefix", "before", "syntax", "line", "token", "position", "file"}
Use amplify to subscribe to a publication and the following functions to contribute suggestions
These suggestions get selected and ranked by CompletePlus. Use this for suggestions you want to make available every time CompletePlus is called.
- suggestion - (Required) - Either suggestionObject or an array of suggestionObjects
These suggestions get selected and ranked by CompletePlus. Use this normally for your suggestions.
- suggestion - (Required) - Either suggestionObject or an array of suggestionObjects
These suggestions get selected and ranked by CompletePlus. In difference to pluginNormal these ones are saved until autocomplete either gets closed or is completed.
- suggestion - (Required) - Either suggestionObject or an array of suggestionObjects
These suggesstions are displayed without any ranking or selection. Use the published pieces of information to select an appropriated suggestion.
- suggestion - (Required) - Either suggestionObject or an array of suggestionObjects
Suggestions of pluginNormal and pluginMajor were delete every time the user types a letter or close the autocomplete.
{"title":
Title of the suggestion - displayed in the autocomplete dialog,
"suggestion":
Suggestion text - Information to rank and select the suggestions,
"ranking":
Text to rank the suggestion,
"callback":
Callback topic for amplify (If callback is an emptry string (""
), CompletePlus completes suggestion with suggestion information),
"isSnippet":
Wheater the suggestion is an snippet or not}
To parse a suggestion use codiad.Complete.pluginParser(suggestion, ranking, title, callback, isSnippet)
- suggestion - (Required) - {String} - Suggestion text
- ranking - (Optional) - {String} - Text to rank the suggestion, if not given or null, ranking = suggestion
- title - (Optional) - {String} - Title to display in the autocomplete dialog, if not given or null, title = suggestion
- callback - (Optional) - {String} - Callback topic for amplify, if not given or null, CompletePlus will finish the completion itself
- isSnippet - (Optional) - {Boolean} - Wheater the suggestion is an snippet or not (snippets allows f.e. tabstops)
To replace the prefix use codiad.Complete.replacePrefix(newValue, isSnippet)
- newValue - (Required) - {String} - Text to replace prefix with
- isSnippet - (Optional) - {Boolean} - If true run suggestion as snippet
init: function() {
amplify.subscribe("Complete.Normal", function(publishObj) {
if (publishObj.syntax == "php") {
var suggestion = codiad.Complete.pluginParser("strtolower");
codiad.Complete.pluginNormal(suggestion);
});}