SpyglassMC / Spyglass

Development tools for vanilla Minecraft: Java Edition data pack developers.
https://spyglassmc.com
MIT License
320 stars 32 forks source link

Embedded Langauge Support in Typescript #1594

Open foopis23 opened 2 months ago

foopis23 commented 2 months ago

I'm working on a library to write data packs in Typescript (https://github.com/foopis23/ts-datapacks). It's helpful to generate long command files using a language many people already know. On top of that, I believe the auto-complete and type-safety features make it easier for beginners.

One feature I have been looking into is getting mcfunction syntax highlighting and language features to work inside embedded strings. Before I learned how to do it and built my own vs-code extension, I figured I would reach out and suggest it as a feature here since it would be convenient to just put people towards this extension instead of making my own and then probably having to suggest using both extensions.

My library uses tag functions to define commands. See the following for an example

const name = "foopis23";
const commandStr = command`say "Hello, ${name}!"`;

I figured it would be a similar implementation to how SQL language features now to highlight anything instead of a tag function named SQL.

The last thing I will say is that, if you guys are open to this, I'm open to changing the tag function name. My library is early in development and nothing is considered stable yet, so I could rename it to like, mcfunc or mc or something like that to make it specific to Minecraft.

foopis23 commented 2 months ago

If this is a feature you guys are interested in, I'd be happy to take a crack at implementing it.

That said, I would probably need someone to point towards to right area to implement it. I looked at the source code and noticed it is a lot more involved then the simple examples on the vscode docs. Still pretty new to extension development so I haven't really worked on anything larger than a couple of files.