zed-d2 icon indicating copy to clipboard operation
zed-d2 copied to clipboard

Use ravsii/tree-sitter-d2 library?

Open dacort opened this issue 8 months ago • 3 comments

Hey @gabeidx! Saw your comment over on https://github.com/zed-industries/zed/issues/28583#issuecomment-2809581193

I had tried to install the extension, but saw it wasn't working for some reason, which led me to bootstrap my own just to see what was going on. Would def love to collaborate!

While going through this process, I noticed there's a more active tree-sitter repo for d2 at https://github.com/ravsii/tree-sitter-d2/

I'm not familiar with tree-sitter at all, so unsure if there's any benefits over being actively maintained, but wanted to open the issue to kick off the discussion.

dacort avatar Apr 17 '25 04:04 dacort

Hey! Glad to see you here and thanks for opening the discussion.

I don't think that fork existed when I created the extension, otherwise I would have used it. Definitely open to replacing the current one.

From a quick look it seems to support more recent features of D2, so it's worth trying it out. Do you want to build it locally and see if it's better?

gabeins avatar Apr 17 '25 14:04 gabeins

nod I'll take a look - I used it in my experiment, but unsure what qualifies as better.

One question - it looks like all the .scm files need to copied in manually, is that accurate?

dacort avatar Apr 17 '25 15:04 dacort

One question - it looks like all the .scm files need to copied in manually, is that accurate?

My (admittedly limited) understanding is that they are the output of tree-sitter generate and then later used by the parser for the syntax highlighting queries.

I followed existing Zed extensions I found, to be honest. It's possible that they could be compiled by the editor when the extension is installed, but I didn't explore that.

but unsure what qualifies as better.

The README in ravsii/tree-sitter-d2 mentions:

My project's initial goal was to fix issues his grammar had, but later I realized that his grammar is not maintained and lacks many features d2 has added since then.

If there are more D2 features that the original grammar doesn't support, I'd say that's definitely better! 😄

gabeins avatar May 23 '25 11:05 gabeins