2025-05-23

Norg / Neorg

So things I need to make:

  • implement scoped links (link to heading)

  • implement footnotes

  • link destination completion

  • anchor reference completion

  • To implement scoped links, I need a rust parser because I have to parse heading markup

  • footnotes can be implemented with new AST architecture

  • link destination completion requires new CST architecture

  • same goes to anchor reference completion

So I have to write rust parser for real.

Norg rust parser

Ok, then how to write the parser? Or in other words, how should I represent the CommonNorg syntax in rust's type system?

At higher level I need:

  • find if a cursor is middle of link destination, anchor reference, or macro identifier (for completion)

  • find linkable / anchor reference / reference-able (e.g. heading) from cursor position

  • find a node based on structural position or node metadata.

I have to traverse the tree anyways so generalized CST is a requirement. But I'm not sure if I need every single leaf nodes like heading prefix or attribute parenthesis.

'-' -> Indent(Unordered) | ParagraphSegment
'.' -> InfirmPrefix | ParagraphSegment
'*' -> HeadingPrefix | Inline(Special)