on master help sign in
Update Julia grammar, queries (#4588)
commit4ec2a21c6e21ab4e515f1bd7ee1049094af2a6b2 authorChrHorn <christoph-horn@hotmail.de> dateSat 5 Nov 2022, 19:30 (4 years ago) parent3814987
3 files changed+39−8
languages.toml+1−1 runtime/queries/julia/highlights.scm+36−6 runtime/queries/julia/locals.scm+2−1
languages.toml+1−1
@@ -604,7 +604,7 @@ indent = { tab-width = 4, unit = " " }
604604
605605[[grammar]]
606606name = "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" }
608608
609609[[language]]
610610name = "java"
runtime/queries/julia/highlights.scm+36−6
@@ -7,13 +7,22 @@
77 (block_comment)
88] @comment
99
10−(((identifier) @constant.builtin) (match? @constant.builtin "^(nothing|missing|Inf|NaN)$"))
11−(((identifier) @constant.builtin.boolean) (#eq? @constant.builtin.boolean "true"))
12−(((identifier) @constant.builtin.boolean) (#eq? @constant.builtin.boolean "false"))
10+(
11+ ((identifier) @constant.builtin)
12+ (#match? @constant.builtin "^(nothing|missing|undef)$"))
13+
14+[
15+ (true)
16+ (false)
17+] @constant.builtin.boolean
1318
1419(integer_literal) @constant.numeric.integer
1520(float_literal) @constant.numeric.float
1621
22+(
23+ ((identifier) @constant.numeric.float)
24+ (#match? @constant.numeric.float "^((Inf|NaN)(16|32|64)?)$"))
25+
1726(character_literal) @constant.character
1827(escape_sequence) @constant.character.escape
1928
@@ -66,7 +75,7 @@
6675(type_parameter_list
6776 (identifier) @type)
6877
69−(constrained_parameter
78+(constrained_type_parameter
7079 (identifier) @type)
7180
7281(subtype_clause
@@ -81,13 +90,32 @@
8190(type_argument_list
8291 (identifier) @type)
8392
93+(where_clause
94+ (identifier) @type)
95+
8496; -------------------
8597; Function definition
8698; -------------------
8799
88100(
89101 (function_definition
90− name: (identifier) @function)
102+ name: [
103+ (identifier) @function
104+ (scoped_identifier
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+ ])
91119 ; prevent constructors (PascalCase) to be highlighted as functions
92120 (#match? @function "^[^A-Z]"))
93121
@@ -101,7 +129,7 @@
101129(optional_parameter
102130 . (identifier) @variable.parameter)
103131
104−(spread_parameter
132+(slurp_parameter
105133 (identifier) @variable.parameter)
106134
107135(function_expression
@@ -185,6 +213,7 @@
185213
186214[
187215 "abstract"
216+ "baremodule"
188217 "begin"
189218 "const"
190219 "do"
@@ -198,6 +227,7 @@
198227 "return"
199228 "struct"
200229 "type"
230+ "where"
201231] @keyword
202232
203233; TODO: fix this
runtime/queries/julia/locals.scm+2−1
@@ -21,7 +21,7 @@
2121(optional_parameter .
2222 (identifier) @local.definition)
2323
24−(spread_parameter
24+(slurp_parameter
2525 (identifier) @local.definition)
2626
2727(function_expression
@@ -33,6 +33,7 @@
3333
3434[
3535 (function_definition)
36+ (short_function_definition)
3637 (macro_definition)
3738] @local.scope
3839