syntect icon indicating copy to clipboard operation
syntect copied to clipboard

Odin Lang Highlight?

Open philocalyst opened this issue 11 months ago • 6 comments

The Odin language (https://odin-lang.org/) is not syntactically highlighted :(

philocalyst avatar Jan 27 '25 20:01 philocalyst

syntect is just a library and can't include syntax definitions for every language under the sun by default. But, as it is a library, you are free to reference whatever syntax definitions you want in your applications which use this library. Looks like there is an official sublime-syntax for Odin at https://github.com/odin-lang/sublime-odin you can use.

keith-hall avatar Jan 27 '25 20:01 keith-hall

A lot of the tooling I use relies on this library and I don't know of a way to update their highlighting as well. To me it's very unclear what has to happen for a highlight to "make it" and be bundled with the library? I mean I can start issues with all of my tooling to add Odin, but I'd rather get it from the source.

I understand this is a very common issue for you, I wish there was a disclaimer somewhere on your policies.

philocalyst avatar Jan 27 '25 23:01 philocalyst

For syntax definitions, syntect quite simply takes the same stance as Sublime Text, and only bundles what Sublime Text bundles. https://github.com/trishume/syntect/issues/168

keith-hall avatar Jan 28 '25 03:01 keith-hall

I've been through the series of issues linking one another, but nowhere did I find an easy way to add a custom syntax file to syntect. Can someone who have done this provide an example of something like just copying some files somewhere and make it loaded by syntect please?

I want to make highlight for my own syntax, so I am willing to write the syntax file, and write build scripts to put it somewhere if that is needed.

Atreyagaurav avatar Mar 21 '25 01:03 Atreyagaurav

nowhere did I find an easy way to add a custom syntax file to syntect. Can someone who have done this provide an example of something like just copying some files somewhere and make it loaded by syntect please?

The syntest example can load sublime-syntax files from a folder, likely you just need to do something similar I imagine: https://github.com/trishume/syntect/blob/master/examples/syntest.rs#L370-L373

keith-hall avatar Mar 21 '25 20:03 keith-hall

Thank you. Althouth the input to that seems to be from commandline, so I was not able to figure out what inputs it takes, but while trying to find out the files it expects from the command line I found the JSON.sublime-syntax file in testfiles which seems to be used here:

https://github.com/trishume/syntect/blob/51c4141be71e39e2f6e3d64a51e0e8b9107ba11e/src/html.rs#L641-L650

This might help. Although I'm using iced to write a text-editor, so I also have to figure out how to change it inside that.

Atreyagaurav avatar Mar 22 '25 02:03 Atreyagaurav