Plugin developers: CodeMirror 6 migration guide for v6.0

Hey plugin developers,

CodeMirror 6.0 is finally stable. That means we’ll be migrating from CM6 v0.19 to v6.0 soon.

In this post I will attempt to summarize everything you need to know about this upcoming migration with breaking changes.

When you upgrade your plugin to target CM6 v6.0, there is a possibility that it no longer works with older versions of Obsidian using CM6 v0.19. If this is the case, you should update your plugin’s manifest.json to indicate that your minAppVersion is 0.15.0, and also add the appropriate entries to versions.json to prevent users with older versions of Obsidian to upgrade your plugin.

Major changes:

  • Prec.fallback/override/extend is now Prec.highest/high/lowest.
  • blockAtHeight, visualLineAtHeight, viewportLines, visualLineAt are now deprecated. The replacements work slightly differently but they should be lineBlockAtHeight, viewportLineBlocks and lineBlockAt.
  • Syntax trees iterate function has changed signature from 3 parameters (node, from, to) to a single object parameter (obj: {node, type, from, to}) (details)
  • scrollPosIntoView, scrollTo, and centerOn is now scrollIntoView
  • Plugin fields no longer exist, and providing decorations from a view plugin now happens by providing a function to the EditorView.decorations facet. Same for atomic ranges and scroll margins — you must use a facet for them now.
  • Many packages has been merged into other packages:
    • text and rangeset are merged into state.
    • tooltip, gutter, panel, and rectangular-selection are merged into view.
    • matchbrackets, stream-parser, fold are merged into language. The custom exports from stream-parser are now available at lishid/cm-language.
    • comment and history are merged into commands.
    • closebrackets is merged into autocomplete.
    • highlight is split into language and @lezer/highlight.

For more minor changes, check out the full breaking release notes.