on master help sign in
Update Julia grammar, queries (#4588)
4ec2a21ChrHorn
languages.toml+1−1
@@ -604,7 +604,7 @@ indent = { tab-width = 4, unit = " " }
604
604
605[[grammar]]
605[[grammar]]
606name = "julia"
606name = "julia"
607−source = { git = "https://github.com/tree-sitter/tree-sitter-julia", rev = "fc60b7cce87da7a1b7f8cb0f9371c3dc8b684500" }
607+source = { git = "https://github.com/tree-sitter/tree-sitter-julia", rev = "8fb38abff74652c4faddbf04d2d5bbbc6b4bae25" }
608
608
609[[language]]
609[[language]]
610name = "java"
610name = "java"
runtime/queries/julia/highlights.scm+36−6
@@ -7,13 +7,22 @@
7 (block_comment)
7 (block_comment)
8] @comment
8] @comment
9
9
10+(
11+ ((identifier) @constant.builtin)
10−(((identifier) @constant.builtin) (match? @constant.builtin "^(nothing|missing|Inf|NaN)$"))
12+ (#match? @constant.builtin "^(nothing|missing|undef)$"))
11−(((identifier) @constant.builtin.boolean) (#eq? @constant.builtin.boolean "true"))
13+
12−(((identifier) @constant.builtin.boolean) (#eq? @constant.builtin.boolean "false"))
14+[
15+ (true)
16+ (false)
17+] @constant.builtin.boolean
13
18
14(integer_literal) @constant.numeric.integer
19(integer_literal) @constant.numeric.integer
15(float_literal) @constant.numeric.float
20(float_literal) @constant.numeric.float
16
21
22+(
23+ ((identifier) @constant.numeric.float)
24+ (#match? @constant.numeric.float "^((Inf|NaN)(16|32|64)?)$"))
25+
17(character_literal) @constant.character
26(character_literal) @constant.character
18(escape_sequence) @constant.character.escape
27(escape_sequence) @constant.character.escape
19
28
@@ -66,7 +75,7 @@
66(type_parameter_list
75(type_parameter_list
67 (identifier) @type)
76 (identifier) @type)
68
77
69−(constrained_parameter
78+(constrained_type_parameter
70 (identifier) @type)
79 (identifier) @type)
71
80
72(subtype_clause
81(subtype_clause
@@ -81,13 +90,32 @@
81(type_argument_list
90(type_argument_list
82 (identifier) @type)
91 (identifier) @type)
83
92
93+(where_clause
94+ (identifier) @type)
95+
84; -------------------
96; -------------------
85; Function definition
97; Function definition
86; -------------------
98; -------------------
87
99
88(
100(
89 (function_definition
101 (function_definition
102+ name: [
103+ (identifier) @function
104+ (scoped_identifier
90− name: (identifier) @function)
105+ (identifier) @namespace
106+ (identifier) @function)
107+ ])
108+ ; prevent constructors (PascalCase) to be highlighted as functions
109+ (#match? @function "^[^A-Z]"))
110+
111+(
112+ (short_function_definition
113+ name: [
114+ (identifier) @function
115+ (scoped_identifier
116+ (identifier) @namespace
117+ (identifier) @function)
118+ ])
91 ; prevent constructors (PascalCase) to be highlighted as functions
119 ; prevent constructors (PascalCase) to be highlighted as functions
92 (#match? @function "^[^A-Z]"))
120 (#match? @function "^[^A-Z]"))
93
121
@@ -101,7 +129,7 @@
101(optional_parameter
129(optional_parameter
102 . (identifier) @variable.parameter)
130 . (identifier) @variable.parameter)
103
131
104−(spread_parameter
132+(slurp_parameter
105 (identifier) @variable.parameter)
133 (identifier) @variable.parameter)
106
134
107(function_expression
135(function_expression
@@ -185,6 +213,7 @@
185
213
186[
214[
187 "abstract"
215 "abstract"
216+ "baremodule"
188 "begin"
217 "begin"
189 "const"
218 "const"
190 "do"
219 "do"
@@ -198,6 +227,7 @@
198 "return"
227 "return"
199 "struct"
228 "struct"
200 "type"
229 "type"
230+ "where"
201] @keyword
231] @keyword
202
232
203; TODO: fix this
233; TODO: fix this
runtime/queries/julia/locals.scm+2−1
@@ -21,7 +21,7 @@
21(optional_parameter .
21(optional_parameter .
22 (identifier) @local.definition)
22 (identifier) @local.definition)
23
23
24−(spread_parameter
24+(slurp_parameter
25 (identifier) @local.definition)
25 (identifier) @local.definition)
26
26
27(function_expression
27(function_expression
@@ -33,6 +33,7 @@
33
33
34[
34[
35 (function_definition)
35 (function_definition)
36+ (short_function_definition)
36 (macro_definition)
37 (macro_definition)
37] @local.scope
38] @local.scope
38
39