terrastruct / d2

D2 is a modern diagram scripting language that turns text to diagrams.
https://d2lang.com
Mozilla Public License 2.0
17.16k stars 425 forks source link

New usage: github-linguist #1352

Open goto1134 opened 1 year ago

goto1134 commented 1 year ago

Since https://github.com/github-linguist/linguist/pull/6435 is merged, the github linguist now supports D2 code detection and code highlighting. This means that d2 will be present in the languages widget and syntax will be highlighted on github.com: image.

Maybe, you want to mention that in your README.

Congratulations, and thank you for your work!

alixander commented 1 year ago

that's amazing, thank you @goto1134 🙌

alixander commented 1 year ago

Github's cut the release and it works now!

Out of curiousity, @goto1134 do you know anything about how linguist works with markdown files? https://github.com/terrastruct/d2/issues/1426 . nvm, was just cache not updating!

alixander commented 1 year ago

i wonder why the syntax color isn't using ours though. i wonder if https://github.com/github-linguist/linguist/discussions/5572#discussioncomment-1355712 is still true and we need to include a tree-sitter implementation in there

edit: or maybe it's not possible. all the samples in there have the same color scheme

goto1134 commented 1 year ago

According to the docs, the TextMate grammar is enough to get the job done. Probably, tree-sitter is mentioned in https://github.com/github-linguist/linguist/discussions/5572#discussioncomment-1355712 to address the issue with Python syntax.

goto1134 commented 1 year ago

@alixander , here is an answer to your question: https://github.com/github-linguist/linguist/discussions/5204#discussioncomment-352539

Linguist doesn't assign the colours. This is entirely controlled by the stylesheet at https://github.com/primer/github-syntax-light (Lightshow uses this one) and https://github.com/primer/github-syntax-dark based on the grammar scopes applied by the grammar.

Here is a summary of the scopes and their colors: https://github.com/Alhadis/language-etc/blob/master/samples/lists/scope-previews.nanorc

So I believe, to solve the problem, we need to change the scopes in the grammar.

alixander commented 1 year ago

ah i see, thank you for looking into that. the predefined list of colors still doesn't have the ones from D2's theme. Oh well, no big deal =)

XoL1507 commented 1 year ago

Thank for all

XoL1507 commented 1 year ago

i wonder why the syntax color isn't using ours though. i wonder if https://github.com/github-linguist/linguist/discussions/5572#discussioncomment-1355712 is still true and we need to include a tree-sitter implementation in there

edit: or maybe it's not possible. all the samples in there have the same color scheme

I will try to work for it.

XoL1507 commented 1 year ago

Can some teach the blue verified?