Skip to content

LanguageConfiguration

Angelo edited this page Aug 22, 2018 · 4 revisions

Language Configuration

org.eclipse.tm4e.languageconfiguration is the project which provides parsing and utilizing *language-configuration.json files.

View the VSCode documentation for more information about the syntax and abilities of these files, however there are differences between the VSCode and TM4E implementations that are outlined below.

Features

With the information supplied from a configuration file, the following features are available to users:

  • Auto Closing Brackets
  • Matching Bracket Highlighting
  • On Enter Actions
  • Toggle Comments
  • Folding (Not yet implemented #50)

Disabling Features

Some users are not fans of certain featues supplied from configuration files. In the TextMate > Language Configuration preference page, users are able to disable the following featues individually:

  • Auto Closing Brackets
  • Matching Bracket Highlighting
  • On Enter Actions

Implementation Differences

Writing a Configuration File

The syntax of the configuration file allows for any combination of the following properties:

  • comments
  • brackets
  • autoClosingPairs
  • surroundingPairs
  • folding
  • wordPattern
  • onEnterRules

onEnterRules

Unlike VSCode onEnterRules are in the configuration file and not in the extension.ts file.

VSCode extension.ts onEnterRule format:

{
    beforeText: /^\s*\/{3}.*$/,
    action: { indentAction: IndentAction.None, appendText: '/// ' },
}

TM4E language-configuration.json onEnterRule format:

{
    "beforeText": "^\\s*/{3}.*$",
    "action":{ "indentAction": "None", "appendText": "/// " }
}

Notice the change in escape format (\) in regex statements and the use of the String version of the IndentAction.

Contributing a Configuration File

For Plugin Developers. use the org.eclipse.tm4e.languageconfiguration.languageConfigurations extension point in your plugin.xml file:

<extension
      point="org.eclipse.tm4e.languageconfiguration.languageConfigurations">
   <languageConfiguration
         contentTypeId="org.eclipse.corrosion.rust"
         path="language-configurations/language-configuration.json">
   </languageConfiguration>
</extension>

For users, go to the TextMate > Language Configuration preference page to associate any *language-configuration.json from either the workspace or file system with a content type.