how connect TM4E (TextMate) to eclipse?

145 views Asked by At

I want to add in my eclipse plugin possibility of syntax highlighting by some regexs. I learned that it is possible to implement through TM4E from eclipse. Where can I find some documentation or tutorials about connection to eclipse?

Eclipse TM4E™ - TextMate support in the Eclipse IDE

I looked for documentation and tutorials anywhere, but it didn't give results.

1

There are 1 answers

2
mami On

First, make sure to add tm4 as a dependecy for your project (edit plugin.xml dependencies).

Then register the content type you want to highlight. Add this to your plugin.xml (The example is for .asm files):

<extension
     point="org.eclipse.core.contenttype.contentTypes">
  <content-type
        priority="normal"
        id="tm4.asm"
        name="Assembly file"
        base-type="org.eclipse.core.runtime.text"
        file-extensions="asm">
  </content-type>
</extension>

Then add your TextMate grammars. Make sure that scopeNameContentTypeBinding content type id matches your content type's id and scope name matches the scope name for the grammar:

  <extension
     point="org.eclipse.tm4e.registry.grammars">
  <grammar
        path="/src/syntaxes/asm.tmLanguage.json"
        scopeName="source.asm">
  </grammar>
  <scopeNameContentTypeBinding
        contentTypeId="tm4.asm"
        scopeName="source.asm">
  </scopeNameContentTypeBinding>
</extension>

Finally, copy your TextMate grammars to the correct location, in this case

/src/syntaxes/asm.tmLanguage.json

Update:

Set the scope name in the grammar as well. Again, scopeName should match the name specified in the tm4e extension point:

{
    "scopeName": "source.asm",
    "name": "ASM",
    "fileTypes": [
       "asm"
    ],
    ....
}