FoldingText uses a slightly modified version of CodeMirror to display and edit text.
I would encourage most plugins to just use FoldingText specific APIs such as Tree
, Node
, and Editor
. But for some things you might want to use CodeMirror directly. That should work fine under the following conditions:
-
You can access the CodeMirror instance using
editor.cm()
. You can access the CodeMirror namespace object usingrequire('codemirror').CodeMirror
. -
CodeMirror and FoldingText's Tree both store their own copy of the text and use change events to stay in sync. If your code is making changes it should only make changes to CodeMirror or FoldingText... not both at the same time.
-
You can't set a CodeMirror mode... FoldingText controls syntax highlighting on its own.
FoldingText also includes many of the modes, keymaps, and other addons that CodeMirror ships with. They are generally off by default, but your plugins can enable them as needed. For example here's how to use the rulers
addon to draw a vertical ruler at the first 6 tab stops:
Extensions.addInit(function (editor) {
var rulers = [];
for (var i = 0; i <= 6; i++) {
rulers.push({className: 'ruler' + i, column: i * 4});
}
editor.cm().setOption('rulers', rulers);
});
Some things should just work. Some might run into problems. If you have some favorite CodeMirror feature that you can't seem to get working let me know and we can try to figure it out together.
Jesse