ACE Editor Autocomplete - Custom Strings


Answer :

you need to add a completer like this

var staticWordCompleter = {     getCompletions: function(editor, session, pos, prefix, callback) {         var wordList = ["foo", "bar", "baz"];         callback(null, wordList.map(function(word) {             return {                 caption: word,                 value: word,                 meta: "static"             };         }));      } }  langTools.setCompleters([staticWordCompleter]) // or  editor.completers = [staticWordCompleter] 

If you want to persist the old keyword list and want to append a new list

var staticWordCompleter = {     getCompletions: function(editor, session, pos, prefix, callback) {         var wordList = ["foo", "bar", "baz"];         callback(null, [...wordList.map(function(word) {             return {                 caption: word,                 value: word,                 meta: "static"             };         }), ...session.$mode.$highlightRules.$keywordList.map(function(word) {         return {           caption: word,           value: word,           meta: 'keyword',         };       })]);      } }  langTools.setCompleters([staticWordCompleter]) // or  editor.completers = [staticWordCompleter]   

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable