on master help sign in
Update slint grammar (#7893)
commit19dff5c3a4c1f41436cc11372e5e7dcbfe197112 authorErasin Wang <erasinoo@gmail.com> dateSun 13 Aug 2023, 15:18 (3 years ago) parentb0c270f
5 files changed+128−79
languages.toml+1−1 runtime/queries/slint/highlights.scm+118−72 runtime/queries/slint/indents.scm+6−5 runtime/queries/slint/injections.scm+2 runtime/queries/slint/locals.scm+1−1
languages.toml+1−1
@@ -2029,7 +2029,7 @@ language-servers = [ "slint-lsp" ]
20292029
20302030[[grammar]]
20312031name = "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" }
20332033
20342034[[language]]
20352035name = "task"
runtime/queries/slint/highlights.scm+118−72
@@ -1,105 +1,153 @@
11
2−(user_type_identifier) @type
2+(identifier) @variable
3+[
4+ (type_identifier)
5+ (units)
6+]@type
37
4−(var_identifier) @variable
8+(array_literal
9+ (identifier) @type)
510
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
718
8−(var_identifier
9− (post_identifier) @variable)
19+(call_expression
20+ function: (identifier) @function)
21+(call_expression
22+ function: (field_expression
23+ field: (identifier) @function))
1024
11−(function_identifier) @function
25+(vis) @keyword.control.import
1226
13−(reference_identifier) @keyword.storage.modifier.ref
14−(visibility_modifier) @keyword.storage.modifier
27+(transition_statement state: (identifier) @variable.other.member)
28+(state_expression state: (identifier) @variable.other.member)
29+(struct_block_definition field: (identifier) @variable.other.member)
30+(assign_property (identifier) @attribute)
1531
1632(comment) @comment
1733
18−(string) @string
19−(int_number) @constant.numeric
20−(unit_type) @type.builtin
34+(string_literal) @string
35+(int_literal) @constant.numeric.integer
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+
2165
2266[
23−"struct"
24−"property"
25−"callback"
26−"import"
27−"from"
28−"root"
29−"parent"
30−"this"
31−"for"
32−"in"
33−"if"
34−"else if"
35−"else"
36−"animate"
37−"states"
38−"when"
39−"in"
40−"out"
41−"transitions"
42−"global"
67+ "root"
68+ "parent"
69+ "duration"
70+ "easing"
71+] @variable.builtin
72+
73+
74+[
75+ "callback"
76+ "animate"
77+ "states"
78+ "out"
79+ "transitions"
80+ "component"
81+ "inherits"
4382] @keyword
4483
4584[
46− "black"
47− "transparent"
48− "blue"
49− "ease"
50− "ease_in"
51− "ease-in"
52− "ease_in_out"
53− "ease-in-out"
54− "ease_out"
55− "ease-out"
56− "end"
57− "green"
58− "red"
59− "red"
60− "start"
61− "yellow"
62− "true"
63− "false"
85+ "black"
86+ "transparent"
87+ "blue"
88+ "ease"
89+ "ease_in"
90+ "ease-in"
91+ "ease_in_out"
92+ "ease-in-out"
93+ "ease_out"
94+ "ease-out"
95+ "end"
96+ "green"
97+ "red"
98+ "start"
99+ "yellow"
100+ "white"
101+ "gray"
64102 ] @constant.builtin
65103
104+[
105+ "true"
106+ "false"
107+] @constant.builtin.boolean
108+
66109"@" @keyword
67110
68111; ; Punctuation
69112[
70113 ","
71114 "."
115+ ";"
116+ ":"
72117] @punctuation.delimiter
73118
74119; ; Brackets
75120[
76−"("
77−")"
78−"["
79−"]"
80−"{"
81−"}"
121+ "("
122+ ")"
123+ "["
124+ "]"
125+ "{"
126+ "}"
82127] @punctuation.bracket
83128
129+(define_property ["<" ">"] @punctuation.bracket)
130+
84131[
85−"angle"
86−"bool"
87−"brush"
88−; "color" // This causes problems
89−"duration"
90−"easing"
91−"float"
92−"image"
93−"int"
94−"length"
95−"percent"
96−"physical-length"
97−"physical_length"
98−"string"
132+ "angle"
133+ "bool"
134+ "brush"
135+ "color"
136+ "duration"
137+ "easing"
138+ "float"
139+ "image"
140+ "int"
141+ "length"
142+ "percent"
143+ "physical-length"
144+ "physical_length"
145+ "string"
99146] @type.builtin
100147
101148[
102149 ":="
150+ "<=>"
103151 "!"
104152 "-"
105153 "+"
@@ -118,8 +166,6 @@
118166 "*="
119167 "/="
120168 "?"
121−
122− "=>"
123− ] @operator
169+ "=>" ] @operator
124170
125171(ternary_expression [":" "?"] @keyword.control.conditional)
runtime/queries/slint/indents.scm+6−5
@@ -1,11 +1,12 @@
11[
2− (field_declaration_list_body)
3− (list_definition_body)
4− (struct_field_declaration_list_body)
2+ (comp_body)
3+ (state_statement)
4+ (transition_statement)
5+ (handler_body)
6+ (consequence_body)
7+ (global_single)
58] @indent
69
710[
811 "}"
9− "]"
10− ")"
1112] @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 @@
11; locals.scm
22
3−(component_definition) @local.scope
3+(component_item) @local.scope