forked from wooorm/starry-night
-
Notifications
You must be signed in to change notification settings - Fork 0
/
source.jsonnet.js
145 lines (144 loc) · 4.61 KB
/
source.jsonnet.js
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is licensed `apache-2.0`.
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.jsonnet', '.libsonnet'],
names: ['jsonnet'],
patterns: [
{match: '\\b(\\d+([Ee][+-]?\\d+)?)\\b', name: 'constant.numeric.jsonnet'},
{
match: '\\b\\d+[.]\\d*([Ee][+-]?\\d+)?\\b',
name: 'constant.numeric.jsonnet'
},
{match: '\\b[.]\\d+([Ee][+-]?\\d+)?\\b', name: 'constant.numeric.jsonnet'},
{
match: '\\bstd[.]is(String|Number|Boolean|Object|Array|Function)\\b',
name: 'support.function.jsonnet'
},
{
match:
'\\bstd[.](acos|asin|atan|ceil|char|codepoint|cos|exp|exponent)\\b',
name: 'support.function.jsonnet'
},
{
match:
'\\bstd[.](filter|floor|force|length|log|makeArray|mantissa|sign)\\b',
name: 'support.function.jsonnet'
},
{
match: '\\bstd[.](objectFields(All)?|objectHas(All)?|equals|prune)\\b',
name: 'support.function.jsonnet'
},
{
match: '\\bstd[.](pow|sin|sqrt|tan|type|max|min|mod|thisFile)\\b',
name: 'support.function.jsonnet'
},
{
match:
'\\bstd[.](abs|assertEqual|escapeString(Bash|Dollars|Json|Python))\\b',
name: 'support.function.jsonnet'
},
{
match: '\\bstd[.](filterMap|flattenArrays|foldl|foldr|format|join)\\b',
name: 'support.function.jsonnet'
},
{
match: '\\bstd[.](mapWithIndex|mapWithKey|deepJoin|mergePatch)\\b',
name: 'support.function.jsonnet'
},
{
match:
'\\bstd[.]manifest(Ini|Python(Vars)?|Json(Ex)?|Yaml(Doc|Stream)|XmlJsonml)\\b',
name: 'support.function.jsonnet'
},
{
match:
'\\bstd[.](lines|map|find|findSubstr|splitLimit|strReplace|ascii(Upper|Lower))\\b',
name: 'support.function.jsonnet'
},
{
match: '\\bstd[.](set|set(Diff|Inter|Member|Union)|sort|resolvePath)\\b',
name: 'support.function.jsonnet'
},
{
match: '\\bstd[.]base64(Decode(Bytes)?)?\\b',
name: 'support.function.jsonnet'
},
{
match:
'\\bstd[.](split|stringChars|substr|toString|startsWith|endsWith)\\b',
name: 'support.function.jsonnet'
},
{
match:
'\\bstd[.](parseInt|parseOctal|parseHex|range|uniq|slice|count)\\b',
name: 'support.function.jsonnet'
},
{match: '\\b[$]\\b', name: 'variable.language.jsonnet'},
{
begin: '"',
end: '"',
name: 'string.double.jsonnet',
patterns: [
{
match: '\\\\[\'"\\\\/bfnrt]',
name: 'constant.character.escape.jsonnet'
},
{
match: '\\\\u[0-9a-fA-F]{4}',
name: 'constant.character.escape.jsonnet'
},
{match: '\\\\[^\'"\\\\/bfnrtu]', name: 'invalid.illegal.jsonnet'}
]
},
{
begin: "'",
end: "'",
name: 'string.single.jsonnet',
patterns: [
{
match: '\\\\[\'"\\\\/bfnrt]',
name: 'constant.character.escape.jsonnet'
},
{
match: '\\\\u[0-9a-fA-F]{4}',
name: 'constant.character.escape.jsonnet'
},
{match: '\\\\[^\'"\\\\/bfnrtu]', name: 'invalid.illegal.jsonnet'}
]
},
{
begin: '@"',
end: '"(?!")',
name: 'string.double.verbatim.jsonnet',
patterns: [{match: '""', name: 'constant.character.escape.jsonnet'}]
},
{
begin: "@'",
end: "'(?!')",
name: 'string.single.verbatim.jsonnet',
patterns: [{match: "''", name: 'constant.character.escape.jsonnet'}]
},
{
begin: '^(\\s*)(.*)(\\|\\|\\|)',
beginCaptures: {3: {name: 'string.block.jsonnet'}},
contentName: 'string.block.jsonnet',
end: '^(?!$)(\\1)(\\|\\|\\|)',
endCaptures: {2: {name: 'string.block.jsonnet'}}
},
{begin: '/\\*', end: '\\*/', name: 'comment.block.jsonnet'},
{match: '//.*$', name: 'comment.line.jsonnet'},
{match: '#.*$', name: 'comment.block.jsonnet'},
{name: 'entity.name.function.jsonnet'},
{match: '\\b(import|importstr)\\b', name: 'storage.type.jsonnet'},
{match: '\\b(function)\\b', name: 'keyword.other.jsonnet'},
{match: '\\b(self|super)\\b', name: 'variable.language.jsonnet'},
{match: '\\b(if|then|else|for|in)\\b', name: 'keyword.control.jsonnet'},
{match: '\\b(local|tailstrict)\\b', name: 'keyword.other.jsonnet'},
{match: '\\b(true|false|null)\\b', name: 'constant.language.jsonnet'},
{match: '\\b(error|assert)\\b', name: 'keyword.control.jsonnet'}
],
scopeName: 'source.jsonnet'
}
export default grammar