Skip to content

Replace RegEx based syntax with external AST parser #300

Open
@alerque

Description

@alerque

We keep mentioning this in various places, but apparently we don't have an issue to track it. Lets try to collect links to relevant tools and discussions to help move towards a syntax highlighter that actually understands Markdown instead of trying to fudge with Regular Expressions.

  1. Neovim has an API for quickly replacing lots of highlights via an asynchronous background job. To date I don't think VIM has anything on par with this feature. Are we okay with a Neovim only improvement? Personally I'm okay with this because I exclusively use Neovim anyway. Since this might be a lot easier to implement with direct API access and VIM support could be added later, I'm totaly okay with putting my own time into Neovim only features. Of course the RegEx could be a fall-back, I wouldn't neuter the plugin for VIM users, only have a less nice set of features.

  2. What, if any, plugin language should we use? Pure VimL might be ideal, but I am not as comfortable with it as Lua or Python, and it's likely much slower. Personally I think if we can make this work in Lua that should be our way forward.

  3. What external parser should be actually use? Ideally this would be Pandoc of course, but it does not currently provide position information in its AST. Until this is implemented or CommonMark-hs is up to speed I don't think we have a practical way forward. I'm not enough of a Haskell ninja to even help on CommonMark yet. The best Lua based Markdown parser I know of is LuaMark (from the same author as Pandoc). Another option might be a filter that takes the Pandoc AST and walks it against the source to inject position information.

With those decisions made, here is a running to-do list of things I think we need to get there:

  • Add a feature flag to toggle the new syntax highlighter so people can use the RegEx ones either by preference or because they don't have the tools. Note this will also make development easier as we can start hacking on it without an expectation of it working yet.
  • Figure out the basic tooling for getting an external AST with source data injected into the syntax highlight system.
  • ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions