How to use custom syntax highlighting in AvaloniaEdit?

450 views Asked by At

I'm trying to use https://github.com/AvaloniaUI/AvaloniaEdit. It works fine, but I can't get my custom syntax highlighting to work.

What functions do I need to use? Which files?

I have all the syntax files, but I don't know which I need.

I'm really sorry for this very basic question, but I really tried a whole day, and it didn't work.

I know that there is this instruction in the README:

Alternatively, if you want to support your own grammars, you just need to install the AvaloniaEdit.TextMate package, and implement IRegistryOptions interface, that's currently the easiest way in case you want to use AvaloniaEdit with the set of grammars different from in-bundled TextMateSharp.Grammars.

But I don't understand what exactly I should do.

Edit: I found out that TextMate isn't required, and I can use the original AvalonEdit's syntax loader, but it would be great if I could use TextMate.

1

There are 1 answers

0
Dmitry On

I'm not quite familiar with Avalonia editor, however, you can check out AlterNET Software Code Editor. Here's a blog post explaining syntax parsing/highlighting: https://www.alternetsoft.com/blog/code-parsing-explained

It supports TextMate grammar as well: https://www.alternetsoft.com/blog/text-mate-parsing