Skip to content

Commit ef7b754

Browse files
angelozerrdatho7561
authored andcommitted
RelaxNG compact textmate+language-configuration support
Signed-off-by: azerr <[email protected]>
1 parent 90142fb commit ef7b754

File tree

4 files changed

+136
-3
lines changed

4 files changed

+136
-3
lines changed

package.json

+21-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
"xml",
1414
"xsl",
1515
"xsd",
16-
"dtd"
16+
"dtd",
17+
"RelaxNG",
18+
"rng",
19+
"rnc"
1720
],
1821
"xmlServer": {
1922
"version": "0.21.1"
@@ -110,13 +113,29 @@
110113
"DTD",
111114
"dtd"
112115
]
116+
},
117+
{
118+
"id": "rnc",
119+
"extensions": [
120+
".rnc"
121+
],
122+
"aliases": [
123+
"RelaxNG Compact",
124+
"rnc"
125+
],
126+
"configuration": "./rnc.language-configuration.json"
113127
}
114128
],
115129
"grammars": [
116130
{
117131
"language": "dtd",
118132
"scopeName": "text.xml.dtd",
119133
"path": "./syntaxes/dtd.tmLanguage.json"
134+
},
135+
{
136+
"language": "rnc",
137+
"scopeName": "source.rnc",
138+
"path": "./syntaxes/rnc.tmLanguage.json"
120139
}
121140
],
122141
"configuration": {
@@ -665,4 +684,4 @@
665684
}
666685
]
667686
}
668-
}
687+
}

rnc.language-configuration.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copy of https://github.com/RussGlover/relaxNgCompactSyntaxHighlighter/blob/master/language-configuration.json
2+
{
3+
"comments": {
4+
"lineComment": "#"
5+
},
6+
// symbols used as brackets
7+
"brackets": [
8+
["{", "}"],
9+
["[", "]"],
10+
["(", ")"]
11+
],
12+
// symbols that are auto closed when typing
13+
"autoClosingPairs": [
14+
["{", "}"],
15+
["[", "]"],
16+
["(", ")"],
17+
["\"", "\""],
18+
["'", "'"]
19+
],
20+
// symbols that that can be used to surround a selection
21+
"surroundingPairs": [
22+
["{", "}"],
23+
["[", "]"],
24+
["(", ")"],
25+
["\"", "\""],
26+
["'", "'"]
27+
]
28+
}

src/client/xmlClient.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function getLanguageClientOptions(
121121
{ scheme: 'file', language: 'dtd' },
122122
{ scheme: 'untitled', language: 'xml' },
123123
{ scheme: 'untitled', language: 'xsl' },
124-
{ scheme: 'untitled', language: 'dtd' },
124+
{ scheme: 'untitled', language: 'dtd' }
125125
],
126126
revealOutputChannelOn: RevealOutputChannelOn.Never,
127127
//wrap with key 'settings' so it can be handled same a DidChangeConfiguration

syntaxes/rnc.tmLanguage.json

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"fileTypes": ["rnc"],
3+
"foldingStartMarker": "\\{\\s*$",
4+
"foldingStopMarker": "^\\s*\\}",
5+
"name": "RelaxNG Compact",
6+
"patterns": [
7+
{
8+
"match": "\\bgrammar\\b",
9+
"name": "keyword.other.grammar.rnc"
10+
},
11+
{
12+
"match": "\\bstart\\b",
13+
"name": "keyword.other.start.rnc"
14+
},
15+
{
16+
"match": "\\b(text|empty|xsd\\:(int|integer|double|date(Time)?|time|string|decimal))\\b",
17+
"name": "storage.type.rnc"
18+
},
19+
{
20+
"captures":
21+
{
22+
"1":
23+
{
24+
"name": "keyword.other.attribute.rnc"
25+
},
26+
"2":
27+
{
28+
"name": "entity.other.attribute.rnc"
29+
}
30+
},
31+
"match": "\\b(attribute)\\s+([a-zA-Z][a-zA-Z_0-9]*)\\s*\\{",
32+
"name": "meta.declaration.attribute.rnc"
33+
},
34+
{
35+
"captures":
36+
{
37+
"1":
38+
{
39+
"name": "keyword.other.element.rnc"
40+
},
41+
"2":
42+
{
43+
"name": "entity.other.element.rnc"
44+
}
45+
},
46+
"match": "\\b(element)\\s+([a-zA-Z][a-zA-Z_0-9]*)\\s*\\{",
47+
"name": "meta.declaration.element.rnc"
48+
},
49+
{
50+
"match": "#.*$",
51+
"name": "comment.hash.rnc"
52+
},
53+
{
54+
"begin": "\"",
55+
"end": "\"",
56+
"name": "string.quoted.double.rnc",
57+
"patterns": [
58+
{
59+
"match": "\\\\.",
60+
"name": "constant.character.escape.rnc"
61+
}]
62+
},
63+
{
64+
"begin": "'",
65+
"end": "'",
66+
"name": "string.quoted.single.rnc",
67+
"patterns": [
68+
{
69+
"match": "\\\\.",
70+
"name": "constant.character.escape.rnc"
71+
}]
72+
},
73+
{
74+
"captures":
75+
{
76+
"1":
77+
{
78+
"name": "entity.other.grammar_production.rnc"
79+
}
80+
},
81+
"match": "\\b([a-zA-Z][a-zA-Z_0-9]*)\\s*=",
82+
"name": "meta.grammar_production.rnc"
83+
}],
84+
"scopeName": "source.rnc",
85+
"uuid": "85F32571-780F-4AAC-BA70-C2229E0B1BDA"
86+
}

0 commit comments

Comments
 (0)