Reputation:
I am working with ace editor in sql mode. I followed this link to enable auto completion: https://github.com/ajaxorg/ace/blob/master/demo/autocompletion.html. It generally works well. However, I want to tweak the auto completion a bit more in order to fulfill my further requirements. Here's wish list:
I am new to this awesome editor. I hope to get some direction on how to tweak the auto completion feature. Thanks.
Upvotes: 5
Views: 7233
Reputation: 24104
There is a pull request to add better completion for sql server mode https://github.com/ajaxorg/ace/pull/2460, sql mode could be handled same way.
to add more words you need to implement a custom completer, which is simple:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajaxorg.github.io/ace-builds/src/ace.js">
</script>
<script src="http://ajaxorg.github.io/ace-builds/src/ext-language_tools.js">
</script>
<style>
#editor { position: absolute; top: 0; left: 0; right: 0; bottom: 0;}
</style>
</head>
<body>
<div id="editor">
press ctrl+space</div>
</body>
<script>
editor = ace.edit("editor")
editor.setOptions({
// mode: "ace/mode/javascript",
enableBasicAutocompletion: true
});
editor.completers.push({
getCompletions: function(editor, session, pos, prefix, callback) {
callback(null, [
{value: "foo", score: 1000, meta: "custom"},
{value: "bar", score: 1000, meta: "custom"}
]);
}
})
</script>
</html>
see also https://github.com/ajaxorg/ace/wiki/How-to-enable-Autocomplete-in-the-Ace-editor
Upvotes: 3