on master help sign in
Update slint grammar (#7893)
19dff5cErasin Wang
languages.toml+1−1
@@ -2029,7 +2029,7 @@ language-servers = [ "slint-lsp" ]
2029
2029
2030[[grammar]]
2030[[grammar]]
2031name = "slint"
2031name = "slint"
2032−source = { git = "https://github.com/jrmoulton/tree-sitter-slint", rev = "0d4dda94f96623302dfc234e06be62a5717f47da" }
2032+source = { git = "https://github.com/jrmoulton/tree-sitter-slint", rev = "00c8a2d3645766f68c0d0460086c0a994e5b0d85" }
2033
2033
2034[[language]]
2034[[language]]
2035name = "task"
2035name = "task"
runtime/queries/slint/highlights.scm+118−72
@@ -1,105 +1,153 @@
1
1
2−(user_type_identifier) @type
2+(identifier) @variable
3+[
4+ (type_identifier)
5+ (units)
6+]@type
3
7
4−(var_identifier) @variable
8+(array_literal
9+ (identifier) @type)
5
10
6−(state_identifier) @variable.other.member
11+(function_identifier) @function
12+[
13+ (image_macro)
14+ (children_macro)
15+ (radial_grad_macro)
16+ (linear_grad_macro)
17+] @function.macro
7
18
8−(var_identifier
19+(call_expression
9− (post_identifier) @variable)
20+ function: (identifier) @function)
21+(call_expression
22+ function: (field_expression
23+ field: (identifier) @function))
10
24
11−(function_identifier) @function
25+(vis) @keyword.control.import
12
26
13−(reference_identifier) @keyword.storage.modifier.ref
27+(transition_statement state: (identifier) @variable.other.member)
14−(visibility_modifier) @keyword.storage.modifier
28+(state_expression state: (identifier) @variable.other.member)
29+(struct_block_definition field: (identifier) @variable.other.member)
30+(assign_property (identifier) @attribute)
15
31
16(comment) @comment
32(comment) @comment
17
33
18−(string) @string
34+(string_literal) @string
19−(int_number) @constant.numeric
35+(int_literal) @constant.numeric.integer
20−(unit_type) @type.builtin
36+(float_literal) @constant.numeric.float
37+
38+[
39+ "in"
40+ "in-out"
41+ "for"
42+] @keyword.control.repeat
43+
44+[
45+ "import"
46+ "export"
47+ "from"
48+] @keyword.control.import
49+
50+[
51+ "if"
52+ "else"
53+ "when"
54+] @keyword.control.conditional
55+
56+[
57+ "struct"
58+ "property"
59+] @keyword.storage.type
60+
61+[
62+ "global"
63+] @keyword.storage.modifier
64+
21
65
22[
66[
23−"struct"
24−"property"
25−"callback"
26−"import"
27−"from"
28−"root"
67+ "root"
29−"parent"
68+ "parent"
30−"this"
69+ "duration"
31−"for"
70+ "easing"
32−"in"
71+] @variable.builtin
33−"if"
72+
34−"else if"
73+
35−"else"
74+[
75+ "callback"
36−"animate"
76+ "animate"
37−"states"
77+ "states"
38−"when"
39−"in"
40−"out"
78+ "out"
41−"transitions"
79+ "transitions"
42−"global"
80+ "component"
81+ "inherits"
43] @keyword
82] @keyword
44
83
45[
84[
46− "black"
85+ "black"
47− "transparent"
86+ "transparent"
48− "blue"
87+ "blue"
49− "ease"
88+ "ease"
50− "ease_in"
89+ "ease_in"
51− "ease-in"
90+ "ease-in"
52− "ease_in_out"
91+ "ease_in_out"
53− "ease-in-out"
92+ "ease-in-out"
54− "ease_out"
93+ "ease_out"
55− "ease-out"
94+ "ease-out"
56− "end"
95+ "end"
57− "green"
96+ "green"
58− "red"
59− "red"
97+ "red"
60− "start"
98+ "start"
61− "yellow"
99+ "yellow"
62− "true"
100+ "white"
63− "false"
101+ "gray"
64 ] @constant.builtin
102 ] @constant.builtin
65
103
104+[
105+ "true"
106+ "false"
107+] @constant.builtin.boolean
108+
66"@" @keyword
109"@" @keyword
67
110
68; ; Punctuation
111; ; Punctuation
69[
112[
70 ","
113 ","
71 "."
114 "."
115+ ";"
116+ ":"
72] @punctuation.delimiter
117] @punctuation.delimiter
73
118
74; ; Brackets
119; ; Brackets
75[
120[
76−"("
121+ "("
77−")"
122+ ")"
78−"["
123+ "["
79−"]"
124+ "]"
80−"{"
125+ "{"
81−"}"
126+ "}"
82] @punctuation.bracket
127] @punctuation.bracket
83
128
129+(define_property ["<" ">"] @punctuation.bracket)
130+
84[
131[
85−"angle"
132+ "angle"
86−"bool"
133+ "bool"
87−"brush"
134+ "brush"
88−; "color" // This causes problems
135+ "color"
89−"duration"
136+ "duration"
90−"easing"
137+ "easing"
91−"float"
138+ "float"
92−"image"
139+ "image"
93−"int"
140+ "int"
94−"length"
141+ "length"
95−"percent"
142+ "percent"
96−"physical-length"
143+ "physical-length"
97−"physical_length"
144+ "physical_length"
98−"string"
145+ "string"
99] @type.builtin
146] @type.builtin
100
147
101[
148[
102 ":="
149 ":="
150+ "<=>"
103 "!"
151 "!"
104 "-"
152 "-"
105 "+"
153 "+"
@@ -118,8 +166,6 @@
118 "*="
166 "*="
119 "/="
167 "/="
120 "?"
168 "?"
121−
122− "=>"
123− ] @operator
169+ "=>" ] @operator
124
170
125(ternary_expression [":" "?"] @keyword.control.conditional)
171(ternary_expression [":" "?"] @keyword.control.conditional)
runtime/queries/slint/indents.scm+6−5
@@ -1,11 +1,12 @@
1[
1[
2− (field_declaration_list_body)
2+ (comp_body)
3− (list_definition_body)
3+ (state_statement)
4− (struct_field_declaration_list_body)
4+ (transition_statement)
5+ (handler_body)
6+ (consequence_body)
7+ (global_single)
5] @indent
8] @indent
6
9
7[
10[
8 "}"
11 "}"
9− "]"
10− ")"
11] @outdent
12] @outdent
runtime/queries/slint/injections.scmnew file+2
@@ -0,0 +1,2 @@
1+((comment) @injection.content
2+ (#set! injection.language "comment"))
runtime/queries/slint/locals.scm+1−1
@@ -1,3 +1,3 @@
1; locals.scm
1; locals.scm
2
2
3−(component_definition) @local.scope
3+(component_item) @local.scope