remarkjs / vscode-remark

Lint and format markdown code with remark
https://marketplace.visualstudio.com/items?itemName=unifiedjs.vscode-remark
MIT License
53 stars 11 forks source link

Support .mdx files #129

Open bencmbrook opened 3 months ago

bencmbrook commented 3 months ago

Initial checklist

Problem

vscode-remark only recognizes markdown files https://github.com/remarkjs/vscode-remark/blob/a6b066c1c3df19e59de4de49152c878d8104264a/src/extension.js#L17

but there is now a dedicated MDX language in VS Code. it would be awesome if we could use remark lint on our MDX files!

Solution

Update the documentSelector to include MDX files

Alternatives

You can force VS Code to treat MDX as Markdown, which allows vscode-remark to work, but it comes at the cost of all the other language features of MDX in VS Code via vscode-mdx

  "files.associations": {
    "*.mdx": "markdown",
  },
JounQin commented 3 months ago

MDX and markdown are definitely different, and there is already vscode-mdx.

github-actions[bot] commented 3 months ago

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.

github-actions[bot] commented 3 months ago

Hi! Thanks for reaching out! Because we treat issues as our backlog, we close issues that are questions since they don’t represent a task to be completed.

See our support docs for how and where to ask questions.

Thanks, — bb

remcohaszing commented 3 months ago

vscode-mdx provides MDX language support. I would also like to see unified-engine based remark support for MDX.

Related issues:

I think those issues need to be resolved first. Then we can investigate support in remark-language-server / vscode-remark. We can implement something like probing in vscode-eslint.

github-actions[bot] commented 3 months ago

Hi team! I don’t know what’s up as there’s no phase label. Please add one so I know where it’s at.

Thanks, — bb

bencmbrook commented 3 months ago

Thank you! Yes my use-case is aligned to that @remcohaszing — showing our remark lint issues in MDX files with IntelliSense.

Our workaround works perfectly today for linting MDX with vscode-remark (by using remark-mdx in our .remarkrc file and forcing VS Code to treat MDX as Markdown via "files.associations") but it comes at the tradeoff of the vscode-mdx extension no longer recognizing the file, since it's treated as Markdown.

bencmbrook commented 3 months ago

@remcohaszing given the extension works with MDX in our workaround... in theory, would updating this to simply include MDX files work? https://github.com/remarkjs/vscode-remark/blob/a6b066c1c3df19e59de4de49152c878d8104264a/src/extension.js#L17 Ideally there would be an exposed setting as well that toggles that so it's opt-in. Also understand if you prefer to go with the more foundational work of handling rule overrides.

Ayc0 commented 2 weeks ago

Cf https://github.com/orgs/mdx-js/discussions/2067#discussioncomment-3023340

Remark-cli and thus remark-vscode are the recommended tools to format MDX

bencmbrook commented 1 week ago

Cf https://github.com/orgs/mdx-js/discussions/2067#discussioncomment-3023340

Remark-cli and thus remark-vscode are the recommended tools to format MDX

Yeah I'm using that for CLI formatting today, but this issue is primarily about highlighting lint errors in the same way that Prettier would, like so:

Screenshot 2024-06-17 at 10 37 15 AM

This is forcebly enabled for MDX in my VSCode via the method described in the Alternatives section in the issue. And these rules are specified via .remarkrc, which includes the remark-vscode plugin