HAML syntax highlighting
mouse 796 · person cloud · link
Last update
2022-06-03
2022
06-03
« — »

jEdit

  1. Append in ~/.jedit/modes/catalog:
1
<MODE NAME="haml" FILE="haml.xml" FILE_NAME_GLOB="*.{haml,haml.erb}" />
  1. put the syntax file from wolfman's blog in ~/.jedit/modes:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?xml version="1.0"?>
<!DOCTYPE MODE SYSTEM "xmode.dtd">
<!--
Edit mode for HAML ~ Version 1.1 - 2006-12-5 by Jim Morris
  1. Place this file in ~/.jedit/modes/haml.xml
  2. Append in ~/.jedit/modes/catalog:
     <MODE NAME="haml" FILE="haml.xml" FILE_NAME_GLOB="*.{haml,haml.erb}" />
Auto indents after lines starting with % with no trailing normal text
(eg. %label{:id => 1}) or starting with "-".
-->
<MODE>
  <PROPS>
    <PROPERTY NAME="lineComment" VALUE="^\s*/" />
    <PROPERTY NAME="noTabs" VALUE="true"/>
    <PROPERTY NAME="wrap" VALUE="none"/>
    <PROPERTY NAME="tabSize" VALUE="2"/>
    <PROPERTY NAME="indentSize" VALUE="2"/>
    <PROPERTY NAME="folding" VALUE="indent"/>
    <PROPERTY NAME="indentNextLines" VALUE="\s*(((%\S+)((\{.+\})|(\[.+\]))?)|(-\s+.*))" />
    <PROPERTY NAME="noWordSep" VALUE="_-"/>
  </PROPS>

  <RULES IGNORE_CASE="TRUE">
    <MARK_FOLLOWING TYPE="MARKUP">%</MARK_FOLLOWING>
    <MARK_FOLLOWING TYPE="KEYWORD2">#</MARK_FOLLOWING>
    <MARK_FOLLOWING TYPE="KEYWORD3">.</MARK_FOLLOWING>

    <EOL_SPAN TYPE="LITERAL3" AT_WHITESPACE_END="TRUE" DELEGATE="ruby::MAIN">=</EOL_SPAN>
    <EOL_SPAN TYPE="LITERAL2" AT_WHITESPACE_END="TRUE" DELEGATE="ruby::MAIN">-</EOL_SPAN>
    <EOL_SPAN TYPE="LITERAL2" AT_WHITESPACE_END="TRUE" DELEGATE="ruby::MAIN">~</EOL_SPAN>

    <SPAN TYPE="LITERAL1" NO_LINE_BREAK="TRUE">
      <BEGIN>"</BEGIN>
      <END>"</END>
    </SPAN>
    <SPAN TYPE="LITERAL1" NO_LINE_BREAK="TRUE">
      <BEGIN>'</BEGIN>
      <END>'</END>
    </SPAN>
    <SPAN TYPE="LITERAL4" NO_LINE_BREAK="TRUE" DELEGATE="ruby::MAIN">
      <BEGIN>{</BEGIN>
      <END>}</END>
    </SPAN>
  </RULES>
</MODE>

Geany

  1. register the new Haml filetype in ~/.config/geany/filetype_extensions.conf
1
2
3
4
5
[Extensions]
Haml=*.haml;*.haml.erb

[Groups]
Markup=Haml;
  1. add the syntax config in ~/.config/geany/filedefs/filetypes.Haml.conf
1
2
3
4
5
6
7
8
9
10
11
# https://geany.org/manual/index.html#filetype-configuration
[styling=Ruby]

[settings]
# https://github.com/geany/geany/tree/master/scintilla/lexilla/lexers
lexer_filetype=Ruby
extension=haml.erb

[indentation]
type=0
width=2