Skip to content

Commit b210d30

Browse files
committed
Update codeit-autocomplete.js
1 parent 0f73dec commit b210d30

File tree

1 file changed

+43
-19
lines changed

1 file changed

+43
-19
lines changed

lib/plugins/codeit-autocomplete.js

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,14 @@ acp.autocomplete = async (lang) => {
167167
* 1. Init function
168168
* ----------------
169169
*
170-
* Every acp language has an init function
171-
* that's called on the first load of a file
172-
* with the language:
170+
* An init function that's called
171+
* on the first load of a file
172+
* containing the defined language:
173173
*
174-
* acp.lang.<lang>.init = () => {
175-
* ...
176-
* acp.lang.<lang>.props = <props>;
177-
* }
174+
acp.lang.<lang>.init = () => {
175+
...
176+
acp.lang.<lang>.props = <props>;
177+
}
178178
*
179179
* Terms:
180180
* <lang> - language name
@@ -184,22 +184,46 @@ acp.autocomplete = async (lang) => {
184184
* 2. Autocomplete function
185185
* ------------------------
186186
*
187-
* Called on every type. Here you can process
188-
* the query and return results:
187+
* Called on every type. Here you can return
188+
* autocomplete results:
189189
*
190-
* acp.lang.<lang>.autocomplete = (query) => {
191-
* ...
192-
* return <results>;
193-
* }
190+
acp.lang.<lang>.autocomplete = (<query>) => {
191+
...
192+
return <results>;
193+
}
194194
*
195195
* Terms:
196-
* query - text of the current line before the cursor.
197-
* newlines, spaces and tabs won't be included.
198-
* <results> - array of strings to show in the autocomplete menu
196+
* <lang> - language name
197+
* <query> - text of the current line before the cursor.
198+
* newlines, spaces and tabs won't be included.
199+
* <results> - array of strings to show in the autocomplete menu.
200+
* these get automatically sorted by relevance.
201+
*
202+
* To disable automatic <results> sorting, return:
203+
return [<results>, { sort: false }];
204+
*
205+
*
206+
* [Optional] 3. Query processing function
207+
* ---------------------------------------
208+
*
209+
* You can define an optional function
210+
* to process the query.
211+
* In this case, an additional parameter, <rawQuery>,
212+
* will be passed to the autocomplete function.
199213
*
200-
* Results are automatically sorted.
201-
* To disable automatic sorting, return:
202-
* return [<results>, { sort: false }];
214+
acp.lang.<lang>.processQuery = (<query>) => {
215+
...
216+
return <procQuery>;
217+
}
218+
*
219+
* Terms:
220+
* <lang> - language name
221+
* <query> - text of the current line before the cursor.
222+
* newlines, spaces and tabs won't be included.
223+
* <procQuery> - proccessed query. this'll be set to the current query
224+
*
225+
* In autocomplete function:
226+
* <rawQuery> - Unproccessed query.
203227
*/
204228

205229

0 commit comments

Comments
 (0)