Search code examples
autocompletecodemirror

Is there a possibility to run autocomplete for an inner mode in codemirror?


I am running freemarker as the inner mode and html as the base mode similar to the mustache template mode. I want to enable the autocompleter for freemarker when it is in the freemarker inner mode. Is it possible to do so.


Solution

  • Yes. If you have an autcompletion function for freemarker register it with CodeMirror.registerHelper("hint", "freemarker", function(editor) { ... }), and the show-hint addon will call it whenever autocompletion is activated in that inner mode.

    This assumes that your inner mode is called "freemarker" (as per its defineMode call), and that your outer mode has a working innerMode method.