Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Julia grammar, queries #4588

Merged
merged 1 commit into from
Nov 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ indent = { tab-width = 4, unit = " " }

[[grammar]]
name = "julia"
source = { git = "https://github.com/tree-sitter/tree-sitter-julia", rev = "fc60b7cce87da7a1b7f8cb0f9371c3dc8b684500" }
source = { git = "https://github.com/tree-sitter/tree-sitter-julia", rev = "8fb38abff74652c4faddbf04d2d5bbbc6b4bae25" }

[[language]]
name = "java"
Expand Down
42 changes: 36 additions & 6 deletions runtime/queries/julia/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@
(block_comment)
] @comment

(((identifier) @constant.builtin) (match? @constant.builtin "^(nothing|missing|Inf|NaN)$"))
(((identifier) @constant.builtin.boolean) (#eq? @constant.builtin.boolean "true"))
(((identifier) @constant.builtin.boolean) (#eq? @constant.builtin.boolean "false"))
(
((identifier) @constant.builtin)
(#match? @constant.builtin "^(nothing|missing|undef)$"))

[
(true)
(false)
] @constant.builtin.boolean

(integer_literal) @constant.numeric.integer
(float_literal) @constant.numeric.float

(
((identifier) @constant.numeric.float)
(#match? @constant.numeric.float "^((Inf|NaN)(16|32|64)?)$"))

(character_literal) @constant.character
(escape_sequence) @constant.character.escape

Expand Down Expand Up @@ -66,7 +75,7 @@
(type_parameter_list
(identifier) @type)

(constrained_parameter
(constrained_type_parameter
(identifier) @type)

(subtype_clause
Expand All @@ -81,13 +90,32 @@
(type_argument_list
(identifier) @type)

(where_clause
(identifier) @type)

; -------------------
; Function definition
; -------------------

(
(function_definition
name: (identifier) @function)
name: [
(identifier) @function
(scoped_identifier
(identifier) @namespace
(identifier) @function)
])
; prevent constructors (PascalCase) to be highlighted as functions
(#match? @function "^[^A-Z]"))

(
(short_function_definition
name: [
(identifier) @function
(scoped_identifier
(identifier) @namespace
(identifier) @function)
])
; prevent constructors (PascalCase) to be highlighted as functions
(#match? @function "^[^A-Z]"))

Expand All @@ -101,7 +129,7 @@
(optional_parameter
. (identifier) @variable.parameter)

(spread_parameter
(slurp_parameter
(identifier) @variable.parameter)

(function_expression
Expand Down Expand Up @@ -185,6 +213,7 @@

[
"abstract"
"baremodule"
"begin"
"const"
"do"
Expand All @@ -198,6 +227,7 @@
"return"
"struct"
"type"
"where"
] @keyword

; TODO: fix this
Expand Down
3 changes: 2 additions & 1 deletion runtime/queries/julia/locals.scm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
(optional_parameter .
(identifier) @local.definition)

(spread_parameter
(slurp_parameter
(identifier) @local.definition)

(function_expression
Expand All @@ -33,6 +33,7 @@

[
(function_definition)
(short_function_definition)
(macro_definition)
] @local.scope

Expand Down