showing results for - "ace editor custom autocomplete"
Eva
06 Jul 2018
1var langTools = ace.require('ace/ext/language_tools');
2
3// data stub:
4var sqlTables = [
5  { name: 'users', description: 'Users in the system' },
6  { name: 'userGroups', description: 'User groups to which users belong' },
7  { name: 'customers', description: 'Customer entries' },
8  { name: 'companies', description: 'Legal entities of customers' },
9  { name: 'loginLog', description: 'Log entries for user log-ins' },
10  { name: 'products', description: 'Products offered in the system' },
11  { name: 'productCategories', description: 'Different product categories' }
12];
13
14// create a completer object with a required callback function:
15var sqlTablesCompleter = {
16  getCompletions: function(editor, session, pos, prefix, callback) {
17    callback(null, sqlTables.map(function(table) {
18      return {
19        caption: table.description,
20	value: table.name,
21	meta: "Table"
22      };
23    }));	
24  }
25};
26// finally, bind to langTools:
27langTools.addCompleter(sqlTablesCompleter);