diff options
| author | Sergio A. Vargas <savargasqu+git@unal.edu.co> | 2022-12-27 04:27:22 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-27 10:27:22 +0100 |
| commit | 0cb637ca9f4389172933e5aba36387ab8430b6fb (patch) | |
| tree | 98f57e02d7a9b0b941a684ad27321362e9a9634f | |
| parent | feat: allow hot-reloading parser after installation (diff) | |
| download | nvim-treesitter-0cb637ca9f4389172933e5aba36387ab8430b6fb.tar nvim-treesitter-0cb637ca9f4389172933e5aba36387ab8430b6fb.tar.gz nvim-treesitter-0cb637ca9f4389172933e5aba36387ab8430b6fb.tar.bz2 nvim-treesitter-0cb637ca9f4389172933e5aba36387ab8430b6fb.tar.lz nvim-treesitter-0cb637ca9f4389172933e5aba36387ab8430b6fb.tar.xz nvim-treesitter-0cb637ca9f4389172933e5aba36387ab8430b6fb.tar.zst nvim-treesitter-0cb637ca9f4389172933e5aba36387ab8430b6fb.zip | |
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.
| -rw-r--r-- | lockfile.json | 2 | ||||
| -rw-r--r-- | queries/julia/highlights.scm | 41 |
2 files changed, 26 insertions, 17 deletions
diff --git a/lockfile.json b/lockfile.json index 7fd333023..0e98edf76 100644 --- a/lockfile.json +++ b/lockfile.json @@ -204,7 +204,7 @@ "revision": "505f5bd90053ae895aa3d6f2bac8071dd9abd8b2" }, "julia": { - "revision": "f254ff9c52e994f629a60821662917d2c6c0e8eb" + "revision": "1cd300bda52e680872053cd55a228c1809cb0c3a" }, "kotlin": { "revision": "b953dbdd05257fcb2b64bc4d9c1578fac12e3c28" diff --git a/queries/julia/highlights.scm b/queries/julia/highlights.scm index 89840dafe..f0b7609f5 100644 --- a/queries/julia/highlights.scm +++ b/queries/julia/highlights.scm @@ -13,7 +13,7 @@ (macro_definition name: (identifier) @function.macro) -(quote_expression ":" (identifier)) @symbol +(quote_expression ":" [(identifier) (operator)]) @symbol (field_expression (identifier) @field .) @@ -71,18 +71,21 @@ ;; Definitions (abstract_definition - name: (identifier) @type.definition) + name: (identifier) @type.definition) @keyword (primitive_definition - name: (identifier) @type.definition) + name: (identifier) @type.definition) @keyword (struct_definition name: (identifier) @type) -(subtype_clause [ - (identifier) @type - (field_expression (identifier) @type .)]) +(type_clause + ["<:" ">:"] @operator + [(identifier) @type + (field_expression (identifier) @type .)]) ;; Annotations -(parametrized_type_expression (_) @type) +(parametrized_type_expression + (_) @type + (curly_expression (_) @type)) (type_parameter_list (identifier) @type) @@ -96,7 +99,9 @@ return_type: (identifier) @type) (where_clause - (identifier) @type) ; where clause without braces + (identifier) @type) +(where_clause + (curly_expression (_) @type)) ;;; Keywords @@ -106,8 +111,6 @@ "local" "macro" "struct" - "type" - "where" ] @keyword "end" @keyword @@ -166,24 +169,30 @@ "return" @keyword.return) [ - "abstract" "const" "mutable" - "primitive" ] @type.qualifier ;;; Operators & Punctuation (operator) @operator -(for_binding ["in" "=" "∈"] @operator) -(range_expression ":" @operator) +(adjoint_expression "'" @operator) +(range_expression ":" @operator) (slurp_parameter "..." @operator) (splat_expression "..." @operator) -"." @operator -["::" "<:"] @operator +((operator) @keyword.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.bracket |
