-
-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathsource.nickel.js
More file actions
130 lines (128 loc) · 3.33 KB
/
source.nickel.js
File metadata and controls
130 lines (128 loc) · 3.33 KB
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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/tweag/nickel>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: [],
names: ['nickel'],
patterns: [
{include: '#keywords'},
{include: '#multiline_strings'},
{include: '#strings'},
{include: '#records'},
{include: '#arrays'},
{include: '#comments'},
{include: '#operators'},
{include: '#numbers'},
{include: '#bools'},
{include: '#storage'},
{include: '#types'},
{include: '#identifiers'}
],
repository: {
arrays: {begin: '\\[', end: '\\]', patterns: [{include: '$self'}]},
bools: {
name: 'constant.boolean',
patterns: [{match: '\\b(true|false)\\b', name: 'constant.boolean'}]
},
comments: {
name: 'comment.line.number-sign',
patterns: [{match: '#(.+)', name: 'comment.line.number-sign'}]
},
identifiers: {
patterns: [
{
match: "\\b[[:upper:]][[:word:]'-]*\\b",
name: 'variable.uppercase-identifier'
},
{
match: "\\b[[:lower:]_][[:word:]'-]*\\b",
name: 'variable.lowercase-identifier'
},
{
match: "\\b'[[:alpha:]][[:word:]-]*\\b",
name: 'constant.other.enum-tag'
},
{
begin: '\\b\'"',
end: '"',
name: 'constant.other.enum-tag',
patterns: [{match: '\\\\.', name: 'constant.character.escape'}]
}
]
},
keywords: {
patterns: [{match: '\\b(if|else|then|match)\\b', name: 'keyword.control'}]
},
multiline_strings: {
begin: 'm(%+)"',
end: '"\\1',
name: 'string.quoted.double',
patterns: [
{match: '\\\\.', name: 'constant.character.escape'},
{include: '#strings_interpolation'}
]
},
null: {
name: 'constant.null',
patterns: [{match: '\\b(null)\\b', name: 'constant.null'}]
},
numbers: {
name: 'constant.numeric',
patterns: [{match: '(\\d+)(\\.\\d+)', name: 'constant.numeric'}]
},
operators: {
name: 'keyword.operator',
patterns: [
{
match:
'(=>|==|=|\\|\\||\\||->|<|>|>=|<=|\\+\\+|\\+|\\-\\$|\\-|\\*|\\/|&&|&|\\.|\\:|@)',
name: 'keyword.operator'
}
]
},
records: {
begin: '\\{',
end: '\\}',
name: 'meta.embedded',
patterns: [{include: '$self'}]
},
storage: {
patterns: [
{
match:
'\\b(let|in|forall|import|default|force|optional|priority|doc|rec)\\b',
name: 'storage.modifier'
},
{match: '\\b(fun)\\b', name: 'storage.type'}
]
},
strings: {
begin: '"',
end: '"',
name: 'string.quoted.double',
patterns: [
{match: '\\\\.', name: 'constant.character.escape'},
{include: '#strings_interpolation'}
]
},
strings_interpolation: {
begin: '%\\{',
end: '\\}',
name: 'meta.embedded',
patterns: [{include: '$self'}]
},
types: {
patterns: [
{match: '\\b(Number|Bool|Dyn|String|Array)\\b', name: 'support.class'}
]
}
},
scopeName: 'source.nickel'
}
export default grammar