Closed kthoms closed 6 months ago
TODO:
Hint: The YAKINDU Solidity-IDE project already contains a hand-written TextMate grammar, see solidity.tmLanguage. This could serve as a good starting point when implementing such a generator fragment.
Hi,
we are thinking about writing one generator fragment for TextMate grammars for our codebase. We would start with something simple (e.g. keywords, maybe comments and strings as suggested above). I think it would be nice if we could contribute it, so I would like to check beforehand what would be the criteria for inclussion.
Do you have any input?
having keywords, strings, ints, comments should be enhough i assume no library at all would be best. (just rich strings as for the other templates) @szarnekow what do you think`?
@rubenporras A contribution would be very welcome. This has been a long standing issue and it's great that you're volunteering to look into it.
Can you please help me understand why you'd need a library that serializes gson for that fragment? I thought textmate grammars are either a sort of xml dialect or a JSON file - would you plan to provide a model along with the serialization to text? Would you consider this one to be some kind of API?
If it's not too cumbersome, a plain text generation is probably the best fit for the existing abstractions.
Keywords as a starter would be fine. Strings and comments as well as other terminals can be added in a subsequent step.
A few questions:
The textmate grammar belongs to the LSP client which is usually not contained within the Xtext project. How would you define the target directory for the generation?
What would be the idea to specialize the tm grammar for other terminal rules?
When you say comments and strings: Would that be based on the definition in Terminals.xtext?
Some languages are case insensitive. Would this be supported by the keyword generation?
Do you have an idea how the generated rules could be unit tested given the specific dialect of regexes in textmate grammars?
Hi @szarnekow,
@rubenporras with you ui plugin: do you mean the .ide or the .ui plugin. in most textmate usescases like vscode there wont be a .ui plugin i guess. am not sure if tm grammars can be merged or if the generation should be a generate once.
@cdietrich , yes, some use cases might not have such .ui plugin, or maybe since it is small (basically the TextMate grammar and the plugin.xml to register a bunch of extension points, like a custom DocumentProvider), one would prefer to have the grammars for all supported DSLs in one plugin (i am actually thinking about that for our product). I can imagine, we could make it configurable. Regarding if grammars can be merged, at least there is an include option, so if strings and comments are the same for all DSLs in a family, a base TextMate grammar could be generated. I was planning that as long temr for our product, specially if I would write the grammars by hand.
Just found this. Is there any update?
not from my side
Hi @cdietrich , we have by now written this generator and have used it internally, similar to https://github.com/eclipse/xtext/pull/2639, it is not fully generic but a bit trimmed down to simplify the implementation given our needs.
Since we are now not working on it actively, I propose that we close the issue, unless you are interested in our implementation. If you are interested, I can go through the code, post the simplifications we did, and if you are still interested, see if we can do a PR.
A first version of it is available on main in https://github.com/eclipse/xtext/tree/main/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/textmate
@rubenporras Maybe you had something different in mind. We'd be happy to apply any improvements to this first version of the fragment.
It would be useful if Xtext could provide a generator fragment that creates a
tmLanguage
TextMate file for the grammar. This can be useful for the creation of language server extensions that make use of TextMate grammars like VSCode. See also #1327