MacRabbit

View Languages

Every Sugar can contain a Languages.xml file at its root. This file defines the rules used to detect what syntax should be used for a document opened in Espresso. It has the following structure:

<?xml version="1.0" encoding="UTF-8"?>
<settings>

    <
language id="your.language.identifier">
        
        <!-- 
Define what syntax this language should use;
              use 
the name of the syntax you defined in Syntaxes -->
        <
root-zone>styling.css</root-zone>

        <!-- 
Human readable name for the language -->
        <
name>CSS</name>

        <!-- 
Ways to detect the language (see next section) -->
        <
detectors>
            ...
        </
detectors>
        
    </
language>

    <
language id="another.language.identifier">
        ...
    </
language>
    
</
settings

Detectors

The most important part in the XML is the <detectors> tag. This tag can contain any number of tags that describe a situation where a file should use this particular language. There are 3 basic types of detectors, and one <combo> tag to combine them.

Extension detector
This detector defines a single extension that activates the language.

<extension>html</extension

Filename detector
This detector defines an entire filename that activates the language. This is useful for special files like .htaccess, Makefile, etc. There is an optional attribute that allows you to make it case sensitive (default is case insensitive).

<filename casesensitive="true">Makefile</filename 

Content matching detector
This detector actually inspects the contents of the file. The optional lines attribute specifies how many lines of the file have to be loaded to inspect the content. The value of this tag is a regular expression, so you are not limited to fixed values.

<match-content lines="2">!DOCTYPE</match-content

Combo detector
Finally, you may only wish to apply a language when a combination of detectors have a positive result. This is possible with the <combo> tag. For example:

<combo>
    <
extension>php</extension>
    <
match-content lines="2">!DOCTYPE</match-content>
</
combo