julia: update parser and highlights (#4035)

- Update patterns for type definitions:
  The grammar was updated to parse `abstract type` and `primitive type`
  as a single token.
- Update @symbol capture to highlight quoted operators as symbols.
- Add pattern to highlight adjoint operator.
- Update patterns and captures for:
  - "keyword" operators (in, isa, where)
  - type operators (<:, >:)
  - Parametrized types.
This commit is contained in:
Sergio A. Vargas 2022-12-27 04:27:22 -05:00 committed by GitHub
parent 7c9ddb72d1
commit 0cb637ca9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 17 deletions

View file

@ -204,7 +204,7 @@
"revision": "505f5bd90053ae895aa3d6f2bac8071dd9abd8b2" "revision": "505f5bd90053ae895aa3d6f2bac8071dd9abd8b2"
}, },
"julia": { "julia": {
"revision": "f254ff9c52e994f629a60821662917d2c6c0e8eb" "revision": "1cd300bda52e680872053cd55a228c1809cb0c3a"
}, },
"kotlin": { "kotlin": {
"revision": "b953dbdd05257fcb2b64bc4d9c1578fac12e3c28" "revision": "b953dbdd05257fcb2b64bc4d9c1578fac12e3c28"

View file

@ -13,7 +13,7 @@
(macro_definition (macro_definition
name: (identifier) @function.macro) name: (identifier) @function.macro)
(quote_expression ":" (identifier)) @symbol (quote_expression ":" [(identifier) (operator)]) @symbol
(field_expression (field_expression
(identifier) @field .) (identifier) @field .)
@ -71,18 +71,21 @@
;; Definitions ;; Definitions
(abstract_definition (abstract_definition
name: (identifier) @type.definition) name: (identifier) @type.definition) @keyword
(primitive_definition (primitive_definition
name: (identifier) @type.definition) name: (identifier) @type.definition) @keyword
(struct_definition (struct_definition
name: (identifier) @type) name: (identifier) @type)
(subtype_clause [ (type_clause
(identifier) @type ["<:" ">:"] @operator
(field_expression (identifier) @type .)]) [(identifier) @type
(field_expression (identifier) @type .)])
;; Annotations ;; Annotations
(parametrized_type_expression (_) @type) (parametrized_type_expression
(_) @type
(curly_expression (_) @type))
(type_parameter_list (type_parameter_list
(identifier) @type) (identifier) @type)
@ -96,7 +99,9 @@
return_type: (identifier) @type) return_type: (identifier) @type)
(where_clause (where_clause
(identifier) @type) ; where clause without braces (identifier) @type)
(where_clause
(curly_expression (_) @type))
;;; Keywords ;;; Keywords
@ -106,8 +111,6 @@
"local" "local"
"macro" "macro"
"struct" "struct"
"type"
"where"
] @keyword ] @keyword
"end" @keyword "end" @keyword
@ -166,24 +169,30 @@
"return" @keyword.return) "return" @keyword.return)
[ [
"abstract"
"const" "const"
"mutable" "mutable"
"primitive"
] @type.qualifier ] @type.qualifier
;;; Operators & Punctuation ;;; Operators & Punctuation
(operator) @operator (operator) @operator
(for_binding ["in" "=" "∈"] @operator)
(range_expression ":" @operator)
(adjoint_expression "'" @operator)
(range_expression ":" @operator)
(slurp_parameter "..." @operator) (slurp_parameter "..." @operator)
(splat_expression "..." @operator) (splat_expression "..." @operator)
"." @operator ((operator) @keyword.operator
["::" "<:"] @operator (#any-of? @keyword.operator "in" "isa"))
(for_binding "in" @keyword.operator)
(for_binding ["=" "∈"] @operator)
(where_clause "where" @keyword.operator)
(where_expression "where" @keyword.operator)
["." "::"] @operator
["," ";"] @punctuation.delimiter ["," ";"] @punctuation.delimiter
["(" ")" "[" "]" "{" "}"] @punctuation.bracket ["(" ")" "[" "]" "{" "}"] @punctuation.bracket