joshdholtz / DeckUI

Swift DSL for writing slide decks in Xcode
MIT License
601 stars 27 forks source link

Possible syntax highlighting collaboration #39

Open mattmassicotte opened 1 year ago

mattmassicotte commented 1 year ago

I literally just finished watching the presentation of DeckUI at Deep Dish, and one part really spoke to me. I've worked a bunch with syntax highlighting, and in fact maintain a number of Swift packages that could potentially be useful. Now the stuff I do may not be a perfect fit, because it is all built to back a general-purpose text editing system. However, it can definitely still do static text.

Neon (https://github.com/chimeHQ/Neon) is a highlighting system. SwiftTreeSitter (https://github.com/chimeHQ/SwiftTreeSitter) is the component that pulls out the syntactic info needed for highlighting.

I think the largest issue is probably with how the tree-sitter works, specifically how you support a language grammar. Each language requires its own Swift package. I've been (very slowly) SPM-ifying the language grammars themselves, but it isn't that hard and there's almost certainly tree-sitter support for whatever language might be of interest.

I figured I'd open up an issue first to talk about it, because in some ways this could be a great collaboration. Also, I’m not sure how this could be more of an over-engineered solution, so seemed appropriate.

mattmassicotte commented 1 year ago

Ok, so I've thought on this some more. I'm now no longer sure Neon is even needed in the static highlighting case. So really, what this could look like is:

All this really isn't too much work, except for the stupid theme part. Tree-sitter pulls out semantic information, but doesn't actually apply colors. This is actually a problem I've wanted to address for a while, so I put together a new repo that I think can bridge the gap between token labels and string attributes. However, it is totally non-functional at the moment.

https://github.com/ChimeHQ/ThemePark

mattmassicotte commented 2 months ago

Just following up here, its been a while now! That ThemePark library is now completely functional and supports Xcode, TextMate, and BBEdit theme formats to various degrees.

So, this is now completely implemenatable!