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
---
name: QML
file_extensions:
- qml
scope: source.qml
version: 2
variables:
identifier: '[A-Za-z_][A-Za-z0-9_]*'
dotted_identifier: '{{identifier}}(?:\.{{identifier}})*'
type_name: '[A-Z][A-Za-z0-9_]*'
dotted_type: '{{type_name}}(?:\.{{type_name}})*'
basic_type: '(?:bool|double|enum|int|list|real|string|url|variant|var|date|point|rect|size)'
contexts:
prototype:
- include: comments
main:
- include: strings
- include: template-strings
- include: import-statements
- include: pragma-statements
- include: object-types
- include: group-attributes
- include: property-declarations
- include: signal-declarations
- include: function-declarations
- include: handler-keywords
- include: binding-targets
- include: js-keywords
- include: constants
- include: function-calls
- include: type-references
- include: operators
comments:
- match: '//.*$'
scope: comment.line.double-slash.qml
- match: '/\*'
push: block-comment
block-comment:
- meta_scope: comment.block.qml
- match: '/\*'
push: block-comment
- match: '\*/'
pop: true
strings:
- match: '"'
push: double-quoted-string
- match: "'"
push: single-quoted-string
double-quoted-string:
- meta_scope: string.quoted.double.qml
- meta_include_prototype: false
- match: '\\.'
scope: constant.character.escape.qml
- match: '"'
pop: true
single-quoted-string:
- meta_scope: string.quoted.single.qml
- meta_include_prototype: false
- match: '\\.'
scope: constant.character.escape.qml
- match: "'"
pop: true
template-strings:
- match: '`'
push: template-string
template-string:
- meta_scope: string.quoted.template.qml
- meta_include_prototype: false
- match: '\\.'
scope: constant.character.escape.qml
- match: '`'
pop: true
import-statements:
- match: '\b(import)\s+({{dotted_identifier}})\b'
captures:
1: keyword.control.import.qml
2: support.type.qml
- match: '\b(import)\b'
scope: keyword.control.import.qml
- match: '\b(as)\b'
scope: keyword.control.as.qml
- match: '\b\d+(?:\.\d+)+\b'
scope: constant.numeric.qml
pragma-statements:
- match: '\b(pragma)\s+({{identifier}})\b'
captures:
1: keyword.control.qml
2: support.type.qml
object-types:
- match: '\b({{dotted_type}})(?=\s*\{)'
captures:
1: entity.name.type.qml
group-attributes:
- match: '\b({{identifier}})(?=\s*\{)'
captures:
1: entity.other.attribute-name.qml
property-declarations:
- match: '\b(default|readonly|required|alias)\b'
scope: storage.modifier.qml
- match: '\b(property)\s+({{dotted_type}}|{{basic_type}}|alias)\s+({{identifier}})\b'
captures:
1: keyword.other.qml
2: support.type.qml
3: variable.parameter.qml
- match: '\b(id)(?=\s*:)'
scope: keyword.other.qml
signal-declarations:
- match: '\b(signal)\s+({{identifier}})\b'
captures:
1: storage.type.qml
2: entity.name.function.qml
function-declarations:
- match: '\b(function)\s+({{identifier}})\b'
captures:
1: storage.type.qml
2: entity.name.function.qml
handler-keywords:
- match: '\b(on[A-Z][A-Za-z0-9_]*(?:Changed)?)\b'
scope: keyword.control.qml
binding-targets:
- match: '\b({{dotted_identifier}})(?=\s*:)'
captures:
1: entity.other.attribute-name.qml
js-keywords:
- match: '\b(?:if|else|for|while|switch|case|break|continue|return|try|catch|finally|throw|new|const|let|var|typeof|instanceof|delete|in|of)\b'
scope: keyword.control.qml
constants:
- match: '\b(?:true|false|null|undefined)\b'
scope: constant.language.qml
- match: '\b(?:0x[0-9A-Fa-f_]+|\d[\d_]*(?:\.\d[\d_]*)?)\b'
scope: constant.numeric.qml
function-calls:
- match: '\b({{identifier}})(?=\s*\()'
captures:
1: support.function.qml
type-references:
- match: '\b({{dotted_type}})\b'
captures:
1: entity.name.type.qml
- match: '\b{{basic_type}}\b'
scope: support.type.qml
operators:
- match: ':'
scope: punctuation.separator.key-value.qml
- match: '\.'
scope: punctuation.accessor.qml
- match: '=>|\?\?|[-+*/%=&|<>!~^]+|\?'
scope: keyword.operator.qml