Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make own grammar ? #385

Open
michalss opened this issue Dec 3, 2023 · 8 comments
Open

How to make own grammar ? #385

michalss opened this issue Dec 3, 2023 · 8 comments

Comments

@michalss
Copy link

michalss commented Dec 3, 2023

Hi is there any docs or sample how to make own grammer please ? I would need modify c# grammer and made some changes. How to do it pls ? There is not any docs.. :(

Regards

@danipen
Copy link
Collaborator

danipen commented Dec 3, 2023

Grammars are provided by TextmateSharp repository.

@michalss
Copy link
Author

michalss commented Dec 3, 2023

Grammars are provided by TextmateSharp repository.

are you sure ?? danipen/TextMateSharp#20 .. btw i dont know where to even start :( please make valuable docs or sample, since there is really nothing useful out there. I would preferer use json or xml from existing grammar...

@danipen
Copy link
Collaborator

danipen commented Dec 3, 2023

What do you need, please describe.

@michalss
Copy link
Author

michalss commented Dec 3, 2023

Okay, please, I need to create my own grammar. I did develop a language very similar to C#, but it will include new keywords. My idea is to take the existing grammar of C# and modify it or simply add some new keywords to existing grammer somehow.

@danipen
Copy link
Collaborator

danipen commented Dec 3, 2023

Yes so you'd need to base on the existing TextmateSharp c# grammar and make your changes from there. No docs are provided 😔

@michalss
Copy link
Author

michalss commented Dec 3, 2023

Yes so you'd need to base on the existing TextmateSharp c# grammar and make your changes from there. No docs are provided 😔

ok thx this is i know i guess but how to load this to AvaloniaEdit without recompile whole lib ? I did not find any way to load custom grammar to AvaloniEdit. There is not such a options or at least i did not find one.. :(

even I use IRegistryOption

 internal class ResmGrammer : IRegistryOptions
 {
     public IRawTheme GetDefaultTheme()
     {
         throw new NotImplementedException();
     }

     public IRawGrammar GetGrammar(string scopeName)
     {
         throw new NotImplementedException();
     }

     public ICollection<string> GetInjections(string scopeName)
     {
         throw new NotImplementedException();
     }

     public IRawTheme GetTheme(string scopeName)
     {
         throw new NotImplementedException();
     }
 }

this is all you get and this does not lead to any custom load or anything else.. So basically i have no idea how to use it in AvaloniaEdit, how to load...

@danipen
Copy link
Collaborator

danipen commented Dec 4, 2023

Yes you need to build custom IRegistryOptions see LocaRegistryOptions usage here.

@Super1Windcloud
Copy link

Does textmate only support C#? When I use other language extensions, nothing happens. It’s still C#’s syntax highlighting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants