Language Plug-Ins
Languages
- Language Plug-ins
- CodeSense
- Languages.xml
- Syntaxes
- Itemizers
- ContextualSettings
Language plug-ins add support for new coding languages to Espresso, or less often modify or extend the language support from another plug-in.
Espresso generates the syntax zones that make up a document using regular expressions defined in syntax definitions within language plug-ins.
Defining a new syntax for Espresso can involve several files and folders:
- Languages.xml: this file defines the rules that determine when your syntax will be used to interpret a document (typically based on file extensions)
- Syntaxes/: the XML file(s) in this folder contain the regex that Espresso uses to parse a document into syntax zones
- SyntaxInjections/: the XML file(s) in this folder define syntax zones to inject into pre-existing syntaxes (see Syntaxes for documentation)
- Itemizers/: the XML file(s) in this folder define how to logically group the syntax zones for your language into larger chunks that can be folded or browsed in the Navigator
- PlaceholderThemes/: the CSS file in this folder is used to add default syntax colors for your new language. See themes for documentation
- ContextualSettings/: the XML files in this folder define language-specific settings for various actions (typically used to customize Espresso's automatic commenting action, but can be leveraged by other actions, as well)
Language plug-in checklist
Although some of these can be done in a different order, these are generally the steps to creating a language plug-in:
- Create a basic plug-in (download basic plug-in template or find more info in plug-in structure)
- Create a Languages.xml file and populate it with basic details for your language
- Create a Syntaxes folder, and start defining your basic syntax zone regex
While working on the syntax zones, you will want to have an example document open so you can make sure that everything is working the way you expect (use the Syntax Inspector to verify). Remember that XML changes to your plug-in require restarting Espresso before you can see the changes!
Once you are happy with the basics of your syntax definition, you can implement Itemizers if you are so inclined, and a placeholder theme. If your language uses non-standard comments, you can define them with ContextualSettings.
Typically you will also want to implement CodeSense in your language plug-in, as well.