Skip to content

Commit 4ec2a21

Browse files
authored
Update Julia grammar, queries (#4588)
1 parent 3814987 commit 4ec2a21

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

languages.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ indent = { tab-width = 4, unit = " " }
604604

605605
[[grammar]]
606606
name = "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]]
610610
name = "java"

runtime/queries/julia/highlights.scm

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)