Skip to content

Commit 4683495

Browse files
committed
First Release of LDIF syntax highlighter.
1 parent c4d7c24 commit 4683495

12 files changed

+926
-0
lines changed

add.sublime-snippet

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<snippet>
2+
<content><![CDATA[
3+
dn: ${1:<Distingushed Name>}
4+
changetype: add
5+
objectclass: ${2:<ObjectClass>}
6+
]]></content>
7+
<tabTrigger>add</tabTrigger>
8+
<scope>text.ldif</scope>
9+
<description>add entry</description>
10+
</snippet>

delete.sublime-snippet

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<snippet>
2+
<content><![CDATA[
3+
dn: ${1:<Distingushed Name>}
4+
changetype: delete
5+
]]></content>
6+
<tabTrigger>delete</tabTrigger>
7+
<scope>text.ldif</scope>
8+
<description>delete entry</description>
9+
</snippet>

global.sublime-completions

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"scope": "text.ldif",
3+
"completions":
4+
[
5+
"version: 1",
6+
"changetype: add",
7+
"changetype: delete",
8+
"changetype: modrdn",
9+
"changetype: modify",
10+
"dn:",
11+
"objectclass:",
12+
]
13+
}

ldif.YAML-tmLanguage

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
# [PackageDev] target_format: plist, ext: tmLanguage
2+
---
3+
name: LDAP Data Interchange Format
4+
scopeName: text.ldif
5+
fileTypes: ["ldif"]
6+
uuid: 471950fc-87e4-4a61-9e3f-93687ec5c381
7+
8+
# Assignment of scopes
9+
# Attribute Names
10+
# Normal attributes --> variable.language.attribute.ldif
11+
# Modify specifications --> entity.name.function.*.ldif
12+
# Special attributes (modrdn, etc.) --> support.constant.attribute.*.ldif
13+
# Master attributes (dn, objectclass, control) --> keyword.other.ldif
14+
# Attribute options --> constant.other.options.ldif
15+
# Attribute Values
16+
# safestring --> string.quoted.safe.ldif
17+
# base64 --> string.quoted.base64.ldif
18+
# url --> stringquoted.url.ldif
19+
# Konstant values (Predefined values)
20+
# Integer --> constant.numeric.ldif
21+
# Meta attributes
22+
# Version --> support.constant.attribute.version.ldif
23+
# Comments --> comment.ldif
24+
# Delimiter --> comment.delimiter.ldif
25+
# Invalid lines
26+
# Containing ivalid characters --> invalid.illegal.character.ldif
27+
# Invalid syntax --> invalid.illegal.syntax.ldif
28+
29+
repository:
30+
comment:
31+
comment: Comments must be reusable because they can also appear within modify blocks.
32+
name: comment.ldif
33+
match: '^\s*#.*$'
34+
35+
check_safestring:
36+
comment: Highlight invalid characters in a LDIF safestring
37+
name: invalid.illegal.character.ldif
38+
match: '[^\r\n\x{01}-\x{09}\x{0B}-\x{0C}\x{0E}-\x{1F}\x{21}-\x{39}\x{3B}\x{3D}-\x{7F}\x{01}-\x{09}\x{0B}-\x{0C}\x{0E}-\x{7F}]+'
39+
40+
check_base64_string:
41+
comment: Highlight invalid characters in a LDIF base64 string
42+
name: invalid.illegal.character.ldif
43+
match: '[^\r\n+/=A-Za-z0-9 ]+'
44+
45+
check_url_string:
46+
comment: Highlight invalid characters in a LDIF url string
47+
name: invalid.illegal.character.ldif
48+
match: "[^\r\na-zA-Z0-9$.+!*(),_{}|\\\\^~\\[\\]`<>#%'\";/?:@&=-]"
49+
50+
51+
attribute_safestring:
52+
comment: Attribute (safe string)
53+
contentName: string.quoted.safe.ldif
54+
begin: '^([a-zA-Z0-9-]+)(;[a-zA-Z0-9;-]+)*:(?![:<])\s*'
55+
beginCaptures:
56+
'1': {name: variable.language.attribute.ldif}
57+
'2': {name: constant.other.options.ldif}
58+
end: "^(?! )"
59+
patterns:
60+
- include: "#check_safestring"
61+
62+
attribute_base64:
63+
comment: Attribute (base64)
64+
contentName: string.quoted.base64.ldif
65+
begin: '^([a-zA-Z0-9-]+)(;[a-zA-Z0-9;-]+)*::\s*'
66+
beginCaptures:
67+
'1': {name: variable.language.attribute.ldif}
68+
'2': {name: constant.other.options.ldif}
69+
end: "^(?! )"
70+
patterns:
71+
- include: "#check_base64_string"
72+
73+
attribute_url:
74+
comment: Attribute (url)
75+
contentName: string.quoted.base64.ldif
76+
begin: '^([a-zA-Z0-9-]+)(;[a-zA-Z0-9;-]+)*:<\s*'
77+
beginCaptures:
78+
'1': {name: variable.language.attribute.ldif}
79+
'2': {name: constant.other.options.ldif}
80+
end: "^(?! )"
81+
patterns:
82+
- include: "#check_url_string"
83+
84+
attribute_special_safestring:
85+
comment: Attribute (safe string)
86+
contentName: string.quoted.safe.ldif
87+
begin: '^(?i:(dn|objectclass))(;[a-zA-Z0-9;-]+)*:(?![:<])\s*'
88+
beginCaptures:
89+
'1': {name: keyword.other.ldif}
90+
'2': {name: constant.other.options.ldif}
91+
end: "^(?! )"
92+
patterns:
93+
- include: "#check_safestring"
94+
95+
attribute_special_base64:
96+
comment: Attribute (base64)
97+
contentName: string.quoted.base64.ldif
98+
begin: '^(?i:(dn|objectclass))(;[a-zA-Z0-9;-]+)*::\s*'
99+
beginCaptures:
100+
'1': {name: keyword.other.ldif}
101+
'2': {name: constant.other.options.ldif}
102+
end: "^(?! )"
103+
patterns:
104+
- include: "#check_base64_string"
105+
106+
delimiter:
107+
comment: Block delimiter for multiple changes.
108+
name: comment.delimiter.ldif
109+
match: '^-$'
110+
111+
rest_is_illegal:
112+
comment: Marks everything else als illegal. Is used as a catch-all statement.
113+
name: invalid.illegal.syntax.ldif
114+
match: ".*"
115+
116+
patterns:
117+
- comment: Version-Line
118+
name: support.constant.attribute.version.ldif
119+
match: 'version:\s*([0-9])(.*)'
120+
captures:
121+
'1': {name: constant.numeric.ldif}
122+
'2': {name: invalid.illegal.syntax.ldif}
123+
124+
- include: "#comment"
125+
126+
- comment: Highlighter for LDAP change record add
127+
name: meta.changetype.add.ldif
128+
begin: '^(changetype):\s(add)$'
129+
beginCaptures:
130+
'1': {name: entity.name.function.add.ldif}
131+
'2': {name: variable.parameter.changetype.add.ldif}
132+
end: '(?=dn)'
133+
patterns:
134+
- include: "#comment"
135+
- include: "#attribute_safestring"
136+
- include: "#attribute_base64"
137+
- include: "#attribute_url"
138+
- include: "#delimiter"
139+
- include: "#rest_is_illegal"
140+
141+
- comment: Highlighter for LDAP change record delete
142+
name: meta.changetype.delete.ldif
143+
begin: '^(changetype):\s(delete)$'
144+
beginCaptures:
145+
'1': {name: entity.name.function.delete.ldif}
146+
'2': {name: variable.parameter.changetype.delete.ldif}
147+
end: '(?=dn)'
148+
patterns:
149+
- include: "#comment"
150+
- include: "#rest_is_illegal"
151+
152+
- comment: "Highlighter for LDAP change record modify"
153+
name: meta.changetype.modify.ldif
154+
begin: '^(changetype):\s(modify)$'
155+
beginCaptures:
156+
'1': {name: entity.name.function.modify.ldif}
157+
'2': {name: variable.parameter.changetype.modify.ldif}
158+
end: '(?=dn)'
159+
patterns:
160+
- include: "#comment"
161+
- comment: "Modification specification (mod-spec)"
162+
name: entity.name.function.modspec.ldif
163+
match: '^(add|delete|replace):\s*([a-zA-Z0-9-]+)(;[a-zA-Z0-9;-]+)*'
164+
captures:
165+
'1': {name: support.constant.attribute.modspec.ldif}
166+
'2': {name: variable.language.attribute.ldif}
167+
'3': {name: constant.other.options.ldif}
168+
- include: "#attribute_safestring"
169+
- include: "#attribute_base64"
170+
- include: "#attribute_url"
171+
- include: "#delimiter"
172+
- include: "#rest_is_illegal"
173+
174+
- comment: "Highlighter for LDAP change record modrdn"
175+
name: meta.changetype.modrdn.ldif
176+
begin: '^(changetype):\s(modrdn)$'
177+
beginCaptures:
178+
'1': {name: entity.name.function.modrdn.ldif}
179+
'2': {name: variable.parameter.changetype.modify.ldif}
180+
end: '(?=dn)'
181+
patterns:
182+
- include: "#comment"
183+
- comment: NewRDN-Attribute with safestring
184+
contentName: string.quoted.safe.ldif
185+
begin: '^(newrdn):(?![:])\s*'
186+
beginCaptures:
187+
'1': {name: entity.name.function.newrdn.ldif}
188+
end: "^(?! )"
189+
patterns:
190+
- include: "#check_safestring"
191+
- comment: NewRDN-Attribute with base64
192+
contentName: string.quoted.base64.ldif
193+
begin: '^(newrdn)::\s*'
194+
beginCaptures:
195+
'1': {name: entity.name.function.newrdn.ldif}
196+
end: "^(?! )"
197+
patterns:
198+
- include: "#check_base64_string"
199+
- comment: DeleteOldRDN-Attribute
200+
name: entity.name.function.deleteoldrdn.ldif
201+
match: '^deleteoldrdn:\s*([01])$'
202+
captures:
203+
'1': {name: constant.numeric.ldif}
204+
- comment: newSuperior-Attribute with safestring
205+
contentName: string.quoted.safe.ldif
206+
begin: '^(newsuperior):(?![:])\s*'
207+
beginCaptures:
208+
'1': {name: entity.name.function.newsuperior.ldif}
209+
end: "^(?! )"
210+
patterns:
211+
- include: "#check_safestring"
212+
- comment: newSuperior-Attribute with base64
213+
contentName: string.quoted.base64.ldif
214+
begin: '^(newsuperior)::\s*'
215+
beginCaptures:
216+
'1': {name: entity.name.function.newsuperior.ldif}
217+
end: "^(?! )"
218+
patterns:
219+
- include: "#check_base64_string"
220+
- include: "#delimiter"
221+
- include: "#rest_is_illegal"
222+
223+
- include: "#attribute_special_safestring"
224+
- include: "#attribute_special_base64"
225+
- include: "#attribute_safestring"
226+
- include: "#attribute_base64"
227+
- include: "#attribute_url"
228+
- include: "#rest_is_illegal"

0 commit comments

Comments
 (0)