/
source.slint.js
163 lines (162 loc) · 5.28 KB
/
source.slint.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/slint-ui/slint-tmLanguage>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.slint'],
names: ['slint'],
patterns: [{include: '#document'}],
repository: {
'block-comments': {
patterns: [
{
begin: '/\\*',
end: '\\*/',
name: 'comment.block',
patterns: [{include: '#block-comments'}]
}
]
},
document: {
patterns: [
{include: '#general'},
{match: '(?<!-)\\b(from|export)\\b(?!-)', name: 'keyword'},
{
match:
'(?<!-)\\b(animate|states|transitions|private|public|pure|function|in|out|in-out)\\b(?!-)',
name: 'keyword.other'
},
{match: '(?<!-)\\b(if|for|return)\\b(?!-)', name: 'keyword.control'},
{
match: '(?<!-)\\b(root|parent|this|self)\\b(?!-)',
name: 'variable.language'
},
{
captures: {
1: {name: 'keyword.other'},
3: {name: 'entity.name.type'},
5: {name: 'entity.name.type'}
},
match:
'(?<!-)\\b(import)\\s*\\{\\s*(([a-zA-Z_][a-zA-Z0-9_-]*)(\\s*,\\s*([a-zA-Z_][a-zA-Z0-9_-]*))*)\\s*\\}'
},
{
captures: {1: {name: 'variable.parameter'}},
match: '(?<!-)\\b([a-zA-Z_][a-zA-Z0-9_-]*)\\s*:'
},
{
captures: {1: {name: 'entity.name.function'}},
match: '(?<!-)\\b([a-zA-Z_][a-zA-Z0-9_-]*)\\s*\\(.*\\)\\s*=>'
},
{
captures: {
1: {name: 'entity.name.function'},
2: {name: 'entity.name.type'}
},
match: '(?<!-)\\b(callback)\\s+([a-zA-Z_][a-zA-Z0-9_-]*)\\s*'
},
{
begin: '(?<!-)\\b(struct)\\s+([a-zA-Z_][a-zA-Z0-9_-]*)\\s*\\{',
beginCaptures: {
1: {name: 'storage.type'},
2: {name: 'entity.name.type'}
},
end: '\\}',
patterns: [
{
captures: {
1: {name: 'variable.parameter'},
2: {name: 'entity.name.type'}
},
match:
'([a-zA-Z_][a-zA-Z0-9_-]*)\\s*:\\s*([a-zA-Z_][a-zA-Z0-9_-]*)\\s*,?'
}
]
},
{
begin: '(?<!-)\\b(global)\\s+([a-zA-Z_][a-zA-Z0-9_-]*)\\s*\\{',
beginCaptures: {
1: {name: 'storage.type'},
2: {name: 'entity.name.type'}
},
end: '\\}',
patterns: [{include: '#property'}]
},
{
begin: '(?<!-)\\b(enum)\\s+([a-zA-Z_][a-zA-Z0-9_-]*)\\s*\\{',
beginCaptures: {
1: {name: 'storage.type'},
2: {name: 'entity.name.type'}
},
end: '\\}',
patterns: [
{match: '([a-zA-Z_][a-zA-Z0-9_-]*)\\s*,?', name: 'entity.name.type'}
]
},
{
captures: {1: {name: 'storage.type'}, 2: {name: 'entity.name.type'}},
match: '(?<!-)\\b(component|inherits)\\s+([a-zA-Z_][a-zA-Z0-9_-]*)'
},
{
captures: {
1: {name: 'variable.parameter'},
2: {name: 'keyword.operator'},
3: {name: 'entity.name.type'}
},
match:
'([a-zA-Z_][a-zA-Z0-9_-])*\\s*(:=)\\s*([a-zA-Z_][a-zA-Z0-9_-]*)'
},
{
match:
'(?<!-)\\b(blue|red|green|yellow|red|black|linear|ease-in-quad|ease-out-quad|ease-in-out-quad|ease|ease-in|ease-out|ease-in-out|ease-in-quart|ease-out-quart|ease-in-out-quart|ease-in-quint|ease-out-quint|ease-in-out-quint|ease-in-expo|ease-out-expo|ease-in-out-expo|ease-in-sine|ease-out-sine|ease-in-out-sine|ease-in-back|ease-out-back|ease-in-out-back|ease-in-circ|ease-out-circ|ease-in-out-circ|ease-in-elastic|ease-out-elastic|ease-in-out-elastic|ease-in-bounce|ease-out-bounce|ease-in-out-bounce|cubic-bezier)\\b(?!-)',
name: 'support.constant'
},
{include: '#property'}
]
},
general: {
patterns: [
{include: '#block-comments'},
{match: '//.*$', name: 'comment.line'},
{
begin: '"',
end: '"',
name: 'string.quoted.double',
patterns: [
{
match: '\\\\(n|\\\\|u\\{\\d+\\}|\\{[^\\}]+\\})',
name: 'constant.character.escape.untitled'
}
]
},
{match: '#([a-fA-F0-9]){3,8}', name: 'constant.other'},
{
match:
'\\b\\d+(\\.\\d*)?(%|px|phx|pt|in|mm|cm|ms|s|deg|rad|turn)?\\b',
name: 'constant.numeric'
}
]
},
property: {
patterns: [
{
begin: '\\b(property)\\b',
beginCaptures: {1: {name: 'keyword.other'}},
end: '(;|:|<=>)',
patterns: [
{
captures: {1: {name: 'entity.name.type'}},
match: '<([a-zA-Z_][a-zA-Z0-9_-]*)>'
},
{match: '[a-zA-Z_][a-zA-Z0-9_-]*', name: 'variable.parameter'},
{match: '\\b(<=>|:)\\b', name: 'keyword.operator'}
]
}
]
}
},
scopeName: 'source.slint'
}
export default grammar