mdx-js / mdx-analyzer

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

Zed Support #458

Open XiNiHa opened 1 month ago

XiNiHa commented 1 month ago

Initial checklist

Problem

Zed is a VSCode-like code editor that has recently gained some popularity. However, it currently doesn't have MDX support, either in first-party integrations or third-party extensions. (see https://github.com/zed-industries/extensions/issues/203)

Solution

Creating an extension for Zed would have a great impact here. Since many Zed extensions work with the LSP protocol, it'd be definitely possible to integrate the MDX language server with Zed, especially considering that other Volar-based language servers like Vue and Astro already support Zed.

Alternatives

Recommend users to stay on VSCode and do nothing

remcohaszing commented 1 month ago

It’s cool to hear people want this. I’m not sure if this repo is the right place to maintain Zed integration though. Perhaps it’s better if Zed adds their own integration. See https://github.com/zed-industries/extensions/issues/203#issuecomment-2230312486.

This is not a definite no. It could be nice to support this from the MDX side if Zed doesn’t want to maintain it.

github-actions[bot] commented 1 month ago

Hi! Thanks for taking the time to contribute! This has been marked by a maintainer as needing more info. It’s not clear yet whether this is an issue. Here are a couple tips:

Thanks, — bb

wooorm commented 1 month ago

:+1: on what remco says there. I’d also say it’s probably easier to maintain by someone who is familiar with and actively using zed, as that’s where most of the complexity is and that’s where a lot of the activity/instability comes from. The MDX side of things is more stable: similar to how any other language is added indeed. LSP / TextMate grammar.

XiNiHa commented 1 month ago

By the way, Zed uses TreeSitter grammars instead of TM, although that wouldn't matter that much AFAIK since we provide the language server anyways.

wooorm commented 1 month ago

tree-sitter is a bit different. I looked into it once. I’ve thought about making a TS grammar when I made the TM grammar. Though, it might not be possible to properly highlight MDX or markdown with TS. See https://github.com/davidmh/mdx.nvim. And also https://github.com/tree-sitter-grammars/tree-sitter-markdown#goals.

XiNiHa commented 1 month ago

I thought that it's possible to provide syntax highlighting just with a language server. Isn't that true? If not a TreeSitter grammar should be worked on for sure 🥲

remcohaszing commented 1 month ago

LSP supports semantic tokens, which can be used to enhance syntax highlighting based on context, for example:

// Is Thing a class? function? interface? This can be determined using semantic tokens
import { Thing } from 'module'

But basic syntax highlighting happens in a grammar such as TextMate, Monarch, or TreeSitter.

wooorm commented 1 month ago

Can only TreeSitter syntaxes expose those semantic tokens? Could they be exposed from TextMate grammars? 🤔

remcohaszing commented 1 month ago

No, the language server exposes them. The point is, yes, the language server enhances syntax highlighting a bit, so you may find some info about that when you search a bit. But it doesn’t provide most highlighting, that’s something for grammars to provide.

wooorm commented 1 month ago

right :+1: it just feels a bit out of place to me for LSP to do that