mdx-js / mdx-analyzer

MDX extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=unifiedjs.vscode-mdx
MIT License
312 stars 18 forks source link

Support embedded languages #287

Open remcohaszing opened 1 year ago

remcohaszing commented 1 year ago

Initial checklist

Problem

It would be nice if we can provide editor features for embedded languages, this includes code blocks and frontmatter.

Solution

The Embedded Programming Languages guide offers some help.

I suggest to use the Request Forwarding method, because this means we support any languages the user has installed. This seems to be bound to Visual Studio Code though, not the language server.

Alternatives

  1. Use the Language Service method, but that means we need to include every language server we want to support, and write a lot of custom logic.
  2. Since Visual Studio Code doesn’t support this in markdown files, we could also make this an external extension that can handle both MDX and markdown based on remark.
remcohaszing commented 8 months ago

I think it’s good to see this into two distinct features:

  1. Frontmatter: Has relatively predictable content.
  2. Code blocks can hold any arbritrary language.

Supporting YAML frontmatter is relatively straight-forward and can be handled using an embedded language, especially now that we use Volar.

For TOML frontmatter and code blocks, we should use request forwarding. This should probably be upstreamed to Volar.