foo123 / editor-grammar

invariant codebase of editor-grammar (codemirror-grammar, ace-grammar,prism-grammar,syntaxhighlighter-grammar, highlightjs-grammar,..)
https://foo123.github.io/
18 stars 7 forks source link

Textmate #9

Open konsumer opened 1 year ago

konsumer commented 1 year ago

I would like to convert textmate JSON language definitions (like those used in VSCode) to this format (so I can convert to other things.) Is this possible? Has someone already made a tool for this?

foo123 commented 1 year ago

Hello, I don't use Textmate so I cannot really tell. But if you follow the instructions in the documentation and get help from the examples for some languages like PHP, HTML, CSS, .. I think it is perfectly possible. The grammar tool is about editors like CodeMirror, ACE, Prism, Highlight.js and SyntxHilighter. The same grammar format (with the exception of the Style Model) can be used the same on all those editors. Hope these help.

konsumer commented 1 year ago

The grammar tool is about editors like CodeMirror, ACE, Prism, Highlight.js and SyntxHilighter. The same grammar format (with the exception of the Style Model) can be used the same on all those editors.

That is the appeal of using it with textmate format for me, since Atom, VSCode, Sublime, and lots of others can use that format. I am not good at converting synhi grammars by hand, so I am hoping to automate and centralize it.

foo123 commented 1 year ago

I am not sure I understand what you want to achieve.. Can you provide an example of the Textmate format and how it would relate to the grammar addon and/or format? Do you mean using Textmate format with CodeMirror or ACE or something different than that?

konsumer commented 1 year ago

Do you mean using Textmate format with CodeMirror or ACE or something different than that?

Yes, that is my eventual goal. Sorry, I will write a concrete example.

So, the umka language seems great. I want to add syntax-highlighting to their playground and this other cool playground. I am dyslexic, and code without syntax-highlighting is very hard for me to read, but it seems like a fun language.

It has sublime text language def. Someone else wrote textmate def and vim. This is great, and textmate is used in many editors now (vscode, for example) but none of them can be converted directly to any web-based code-editors (like codemirror or Ace.)

I saw this project, which appears to have the goal of being a single grammar-type that can be converted into other things. That seems perfect, as I can get the format in something central, and convert it to codemirror, in this case. I am not great with language-parsing grammars, so I think "maybe there is some existing tool, or this is a feature someone who is better than me at this can implement" so I make an issue over here and here, looking for help.

My goal is "if your editor-grammar doesn't support editors like sublime and vscode, it could, and that would even be more useful." In this case it would mean I can convert the sublime YAML def or textmate JSON into an online code-editor.

So I want to go like this:

graph TD
    subl[Sublime Text] --> eg[editor-grammar] --> Codemirror
    txm[Vscode/Textmate] --> eg[editor-grammar]

But might also be cool to go like this:

graph TD
     eg[editor-grammar] --> subl[Sublime Text]
     eg[editor-grammar] --> txm[Vscode/Textmate]
     eg[editor-grammar] --> vim[Vim]
    eg[editor-grammar] --> cm[Codemirror]
    eg[editor-grammar] --> ace[Ace]

And then I can try to port the Textmate grammar to editor-grammar (maybe with some help from umka people,) and have all the editors covered with 1 grammar.

foo123 commented 1 year ago

Ah, I see now. The second option is only possible if the editor is implemented in javascript (eg Textmate run in javascript) or a new editor-grammar tool is implemented in the language of the editor (eg in C instead of javascript). For the first option (transform a textmate grammar to editor grammar to be used with codemirror) it is possible, but I don't know of an automated way to do this, but going step-by-step one can transform a grammar in textmate format to a grammar for editor-grammar most easily. I will label this question, to remind me to chek textmate format and maybe integrate it into editor-grammar if I find time.