ace editor enable basic autocomplete code example
Example: ace editor custom autocomplete
var langTools = ace.require('ace/ext/language_tools');
var sqlTables = [
{ name: 'users', description: 'Users in the system' },
{ name: 'userGroups', description: 'User groups to which users belong' },
{ name: 'customers', description: 'Customer entries' },
{ name: 'companies', description: 'Legal entities of customers' },
{ name: 'loginLog', description: 'Log entries for user log-ins' },
{ name: 'products', description: 'Products offered in the system' },
{ name: 'productCategories', description: 'Different product categories' }
];
var sqlTablesCompleter = {
getCompletions: function(editor, session, pos, prefix, callback) {
callback(null, sqlTables.map(function(table) {
return {
caption: table.description,
value: table.name,
meta: "Table"
};
}));
}
};
langTools.addCompleter(sqlTablesCompleter);