I'm using ace editor and I've enabled basicautocompletion and I'm pulling data from another server to get the suggestions. Everything works fine, but I want to remove the local suggestions from the suggestion box.
Here is my relevant code:
var langTools = ace.require("ace/ext/language_tools");
var editor = ace.edit("editor");
editor.setTheme("ace/theme/xcode");
var TextMode = require("ace/mode/text").Mode;
editor.getSession().setUseWrapMode(true);
editor.setOptions({
enableBasicAutocompletion: true,
});
var qtags = {
getCompletions: function(editor, session, pos, prefix, callback) {
$.getJSON(jsonURL,
function(tagList) {
callback(null, tagList.map(function(qtag) {
return {name: qtag.name, value: "#"+qtag.name+"() ", meta: "qtag"}
}));
})
}
}
langTools.addCompleter(qtags);
Here is how it looks like:
I've tried this line to remove all completers before adding my qtag completer, but that doesn't remove the local variables
langTools.completers = [];
Any input would be appreciated, I'm trying to avoid having to modify ace/ext/language_tools.js if possible, but at this point I'm open even to that option.
The trick is to call
langTools.setCompleters([])
before callingeditor.setOptions({enableBasicAutocompletion: true});
. May be its a good idea to set this option explicit tofalse
before setting or adding the Completers. There is no need to change the sourcecode of the language_tools.Example:
you can use
langTools.setCompleters
or
editor.completers = [langTools.snippetCompleter, langTools.textCompleter, qtags]