I’m using CodeMirror to author mixed-content documents (primarily a custom language mode embedded into markdown codeblocks). Unfortunately, when I use the custom language mode by itself, indentation works as expected, but when it’s used as a sub-mode of GFM, indentation appears to purely follow the previous line’s indentation level. The codeblock has the appropriate language identifier. All syntax highlighting still works, and the custom mode is actually working, it just isn’t in control of indentation.
The custom mode is written using the simple mode addon, and I dropped a console.log
into codemirror/addon/mode/simple.js#L195
and confirmed that, when used directly the function is invoked for indentation, but when used as a submode it is not.
This is the snipped setup for the editor. All the custom-mode specific setup is in the codemirror-mode-eve
module.
import * as CodeMirror from "codemirror";
import "codemirror-mode-eve";
// GFM-embedded multi-mode editing for Eve Documents.
import "codemirror/addon/mode/overlay";
import "codemirror/addon/mode/multiplex";
import "codemirror/mode/gfm/gfm";
import "codemirror/mode/markdown/markdown";
//////////////////////////////////////////////////////////////////////
// Settings
//////////////////////////////////////////////////////////////////////
editor.setOption("keyMap", "emacs");
editor.setOption("tabSize", 2);
editor.setOption("indentUnit", 2);
editor.setOption("autoClearEmptyLines", true);
editor.setOption("smartIndent", true);
editor.setOption("electricChars", true);
editor.setOption("mode", "gfm");
Is there anything obviously wrong with my setup? If not I’d be happy to move this to GitHub issues and provide any additional diagnostic information that might be useful.