Skip to content

Conversation

dfreeman
Copy link
Collaborator

This will highlight Unison code in appropriately-tagged code blocks in any Markdown files (including transcripts).

Fixes #20 — I happened to have an example of this for another language at hand, originally cobbled together from the official extension development docs and this example.

image

You could imagine doing a few other things to make this nicer, like highlighting :hide and friends as their own tokens or highlighting the project/branch> prompt differently in ucm blocks, but just getting unison blocks working seems like an ok starting point.

Note: I also included a launch config file for running the extension in a debug Code instance, because I can never remember the incantation to do that manually and like being able to just hit F5. I'm happy to drop that if you'd rather not have it included in the repo, though.

@dfreeman dfreeman requested a review from ChrisPenner June 25, 2025 10:18
Copy link
Collaborator

@BenFradet BenFradet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool initiative 👍

"type": "extensionHost"
}
]
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this belong in a contributing guide or the readme?

@ChrisPenner
Copy link
Member

Fantastic, thanks for putting this together! And yeah, the launch.json is a great idea I didn't know that was a thing :)

Unfortunately it doesn't appear to be working for me 🤔

image

I've tried with both the extension host and manually building and installing a .vsix; I'm not well-versed in debugging a syntax extension, do you have any ideas of what I could try to fix it?

VS Code is showing "Markdown" in the bottom corner so it knows I'm in a Markdown doc :)

@dfreeman
Copy link
Collaborator Author

dfreeman commented Jul 8, 2025

Sorry @ChrisPenner, I've been on vacation and mostly not at a keyboard.

What Markdown extension(s) do you have installed? (I'm assuming you otherwise get syntax highlighting for e.g. **bold text**?)

The most useful info for debugging is probably getting the effective tokenization/scope info that Code has computed, which you can do by opening the command palette and selecting Developer: Inspect Editor Tokens and Scopes. The two relevant tokens for the injection should be the triple-backtick and the unison immediately after it, which by way of example for me gives this info:

image image

And then results in the text inside having the meta.embedded.block.unison scope:

image

@aryairani
Copy link
Contributor

I was able to try it out today, huge improvement! I did get meta.embedded.block.unison.

image

No idea though what I might have done righter than @ChrisPenner though?

@ChrisPenner
Copy link
Member

@dfreeman I do indeed get markdown highlighting for everything else.

When I enable debugging here's what I see:

image

Highlighting works for javascript blocks, (not Haskell though for some reason, maybe that's not included by default).

I don't have any markdown extensions so I'd be surprised if anything was interfering there; and I tried using both the extension host and uninstall the unison plugin and using a .vsix instead; no luck.

At any rate, if it's working for you and Arya and friends it appears the issue is somewhere on my end, so I'm more than happy to merge and move on. Maybe my computer will smarten up at some point in the future. Somewhat ironically, despite maintaining this extension I don't actually use VS Code very often haha.

I'll get a release out for this, thanks for the contribution!

@ChrisPenner ChrisPenner merged commit a3c29be into main Jul 8, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

syntax highlighting in transcript file unison blocks?
4 participants