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 calling editor.setOptions({enableBasicAutocompletion: true});
. May be its a good idea to set this option explicit to false
before setting or adding the Completers. There is no need to change the sourcecode of the language_tools.
Example:
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);
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.setCompleters([qtags]);
editor.setOptions({
enableBasicAutocompletion: true,
});
you can use langTools.setCompleters
langTools = require("ace/ext/language_tools")
langTools.setCompleters([langTools.snippetCompleter, langTools.textCompleter])
or editor.completers = [langTools.snippetCompleter, langTools.textCompleter, qtags]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With