Support syntax highlighting of embedded dart and haxe code
Closed this issue · 5 comments
Please add support for embedded syntax highlighting for Dart and Haxe. The textmate scope names are source.dart and source.haxe
Dart Example
import 'package:hotreloader/hotreloader.dart';
Future<void> main(List<String> args) async {
final reloader = await HotReloader.create(
debounceInterval: Duration(seconds: 2), // wait up to 2 seconds after file change before reloading
onBeforeReload: (ctx) =>
ctx.isolate.name != 'foobar' && // never reload the isolate named 'foobar'
ctx.event?.path.contains('/mymodel/')) ?? true, // only perform reload when dart files under ../mymodel/ are changed
onAfterReload: (ctx) => print('Hot-reload result: ${ctx.result}')
);
// ... your other code
await reloader.reloadCode(); // programmatically trigger code reload
// ... your other code
// cleanup
reloader.stop();
}
Haxe Example
class Game {
// Haxe applications have a static entry point called main
static function main() {
// Anonymous structures.
var playerA = { name: "Simon", move: Paper }
var playerB = { name: "Nicolas", move: Rock }
// Array pattern matching. A switch can return a value.
var result = switch [playerA.move, playerB.move] {
case [Rock, Scissors] |
[Paper, Rock] |
[Scissors, Paper]: Winner(playerA);
case [Rock, Paper] |
[Paper, Scissors] |
[Scissors, Rock]: Winner(playerB);
case _: Draw;
}
// Paper vs Rock, who wins?
trace('result: $result');
}
}
// Allow anonymous structure named as type.
typedef Player = { name: String, move: Move }
// Define multiple enum values.
enum Move { Rock; Paper; Scissors; }
// Enums in Haxe are algebraic data type (ADT), so they can hold data.
enum Result {
Winner(player:Player);
Draw;
}
Hey!
We can’t add every language. Why should this one be included?
Much in this project is generated. You can also do this yourself:
Line 119 in 11eeefe
We can’t add every language. Why should this one be included?
For Haxe I understand the question as it is a niche language but relatively popular amongst game developers. My answer in this case would be: "because I use it" :)
Dart on the other hand is amongst the 20 most popular programming languages ahead of Rust and Kotlin and way ahead of some of languages which are already support by this project. So I feel it should be obvious to support it and if there are performance concerns, maybe one of the less popular languages like coffeescript or elm clould be dropped in exchange for dart. https://spectrum.ieee.org/the-top-programming-languages-2023
Why not generate your own bundle? You can choose what you want to support.
haxe is not convincing to me.
I am including the textmate grammar in a scheduled build to automatically included the latest improvements. Having to manually alter the build.js seems error prone and defeats that purpose. If additional grammars included could be provided by some cli argument or a separate flat file to the build process it would simplify things.
You can have your own fork? And pull in changes from upstream while keeping your own changes as well?
I would accept a PR that adds a CLI for this repo.
I’d also accept a PR adding dart for everyone.
But I am not convinced adding haxe for everyone is a positive.
Thanks!