I need to add a new language in Gedit. The problem is, it is included in Gedit menu of languages now, but its syntax is not highlighted and Gedit is not able to indentify the language just from the file suffix.
I’ve created both .lang file and a XML file describing MIME-TYPE.
LANG file - /usr/share/gtksourceview-3.0/language-specs/test.lang
MIME-TYPE file - /usr/share/mime/packages/test.xml
After creating them I’ve updated the mime database.
sudo update-mime-database /usr/share/mime
Next attempts
1) I’ve tried even copying test.xml
file to /usr/share/mime/applications
folder instead of /usr/share/mime/packages
, but it had no effect.
2) I’ve tried to put the mime type into the /etc/mime.types
as
text/x-test test
and it had no effect too.
test.lang
<?xml version="1.0" encoding="UTF-8"?>
<language id="test" _name="Test" version="1.0" _section="Source">
<metadata>
<property name="mimetypes">text/x-test</property>
<property name="globs">*.test</property>
<property name="line-comment-start">//</property>
<property name="block-comment-start">/*</property>
<property name="block-comment-end">*/</property>
</metadata>
<styles>
<style id="comment" _name="Comment" map-to="def:comment"/>
<style id="keyword" _name="Keyword" map-to="def:keyword"/>
</styles>
<definitions>
<context id="if0-comment" style-ref="comment">
<start>%{preproc-start}ifbs*0b</start>
<end>%{preproc-start}(endif|else|elif)b</end>
<include>
<context id="if-in-if0">
<start>%{preproc-start}if(n?def)?b</start>
<end>%{preproc-start}endifb</end>
<include>
<context ref="if-in-if0"/>
<context ref="def:in-comment"/>
</include>
</context>
<context ref="def:in-comment"/>
</include>
</context>
<context id="keywords" style-ref="keyword">
<keyword>hello</keyword>
<keyword>hi</keyword>
</context>
<!--Main context-->
<context id="test">
<include>
<context ref="if0-comment"/>
<context ref="keywords"/>
</include>
</context>
</definitions>
</language>
test.xml
<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info" >
<mime-type type="text/x-test">
<sub-class-of type="text/plain"/>
<comment xml:lang="en">TEST language document</comment>
<comment xml:lang="cs">Dokument v jazyce TEST</comment>
<glob pattern="*.test"/>
</mime-type>
</mime-info>