New plugin: Orgmode CM6

Introducing Orgmode CM6, my first obsidian plugin that allows to view/edit orgmode files (*.org), as opposed to markdown files (*.md). I am using it on desktop for my orgmode files coming from my phone with orgzly.

I was previously using obsidian-org-mode and wanted to customize the experience with some JS/CSS but was frustrated that it was using code mirror 5 like the legacy editor (feature removed in obsidian 1.5) and not code mirror 6 like current obsidian. So I wrote this plugin from scratch to do just that (CM6 is for code mirror 6), and a little more:

  • The syntax highlighting is not based on regexes but on a custom lezer grammar so it is much more accurate, even though not all orgmode syntax is implemented.
  • There are CSS classes to customize the syntax highlighting.
  • You can define your own todo/done keywords for the syntax highlighting.

Still not a fully-featured orgmode editor, but I hope it can be useful.

I would love to have your feedback about the plugin. I am also curious to know more about your orgmode/obsidian workflows, if you are into that.

7 Likes

I was hoping that someone would be brave enough to do this. Thank you so very much!

I’ll try out the plugin this weekend.

Initially when I was at least contemplating the idea of doing it myself, I looked at Lezer (nice idea like tree-sitter), but then I saw that CM6’s markdown mode was NOT done with lezer, I think due to its flexibility which supports a.o. embedded code blocks that also need to be correctly parsed. Does your parser support code blocks?

Thank you.

By CM6’s markdown mode, are you talking about @codemirror/lang-markdown which uses @lezer/markdown? It was done with lezer, just not using a grammar file. Markdown and Orgmode are similar in that their grammars are not context-free and cannot be expressed as a LR parser, but there are ways to implement them with Lezer.

My parser relies on external tokens. It doesn’t currently support code blocks, but there is no fundamental reason it couldn’t be implemented. CodeMirror and Lezer call this feature Mixed-Language Parsing.

Is that a feature you would be interested to use, or do you just want to know what is possible?

Hi @bbazard , I want to use this plugin on iPhone, is it possible?

Hi,

This plugin was not implemented on mobile. I never tried it on iOS but I tried it once on android and it didn’t work.

I am guessing some configuration is needed to make obsidian handle *.org files.
Since I don’t use obsidian on mobile, I didn’t look at how to make it work.

You can disable a flag in the manifest.json in your .obsidian to activate the plugin on mobile as described in Hacking Obsidian: Making a Desktop-only Plugin Work on your Phone or Tablet | Medium but it will probably still not work.

New version 2.0.0 available :tada:

  • The plugin now works on android and iOS
  • The orgmode files are now auto-saved
  • Experimental CodeBlockProcessor to see orgmode tasks in markdown files

See the details and a video of the experimental feature: Release 2.0.0 · BBazard/obsidian-orgmode-cm6 · GitHub