diff options
| author | Fredrik Ekre <ekrefredrik@gmail.com> | 2024-11-22 16:51:33 +0100 |
|---|---|---|
| committer | Christian Clason <ch.clason+github@icloud.com> | 2024-11-23 11:10:05 +0100 |
| commit | 3f377c07390cd2a79de237ff00946a51d4d8c2a8 (patch) | |
| tree | fc438a7179c448c61fa65fddd4c9efdf5e6484a4 | |
| parent | fix(astro): highlight self-closing component tags (diff) | |
| download | nvim-treesitter-3f377c07390cd2a79de237ff00946a51d4d8c2a8.tar nvim-treesitter-3f377c07390cd2a79de237ff00946a51d4d8c2a8.tar.gz nvim-treesitter-3f377c07390cd2a79de237ff00946a51d4d8c2a8.tar.bz2 nvim-treesitter-3f377c07390cd2a79de237ff00946a51d4d8c2a8.tar.lz nvim-treesitter-3f377c07390cd2a79de237ff00946a51d4d8c2a8.tar.xz nvim-treesitter-3f377c07390cd2a79de237ff00946a51d4d8c2a8.tar.zst nvim-treesitter-3f377c07390cd2a79de237ff00946a51d4d8c2a8.zip | |
fix(julia): treat :: as operator in type contexts
This patch captures `::` as `@operator` within
`(unary_typed_expression)` and `(typed_expression)`. These should be the
only two cases that the parser can emit when encountering `::` in the
source, but as a fallback it is still captured as `@punctuation` in all
other cases.
The reasons for capturing `::` as an operator are i) the close relation
with the other type-operators `<:` and `>:` and ii) the fact that it is
treated as an operator by the Julia parser, just like `<:` and `>:`.
| -rw-r--r-- | queries/julia/highlights.scm | 8 | ||||
| -rw-r--r-- | tests/query/highlights/julia/test.jl | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/queries/julia/highlights.scm b/queries/julia/highlights.scm index 6988e69f5..789f8190c 100644 --- a/queries/julia/highlights.scm +++ b/queries/julia/highlights.scm @@ -281,6 +281,14 @@ "::" ] @punctuation.delimiter +; Treat `::` as operator in type contexts, see +; https://github.com/nvim-treesitter/nvim-treesitter/pull/7392 +(typed_expression + "::" @operator) + +(unary_typed_expression + "::" @operator) + [ "(" ")" diff --git a/tests/query/highlights/julia/test.jl b/tests/query/highlights/julia/test.jl index 445efaa1f..338b7f8a1 100644 --- a/tests/query/highlights/julia/test.jl +++ b/tests/query/highlights/julia/test.jl @@ -2,13 +2,13 @@ function load_data(::Symbol; ::Int) :: Tuple # <- @keyword.function # ^ @function.call # ^ @punctuation.bracket -# ^^ @punctuation.delimiter +# ^^ @operator # ^ @type.builtin # ^ @punctuation.delimiter -# ^^ @punctuation.delimiter +# ^^ @operator # ^^^ @type.builtin # ^ @punctuation.bracket -# ^^ @punctuation.delimiter +# ^^ @operator # ^ @type.builtin dataset = CIFAR10(; Tx = Float32, split = split) # ^^^^^^^ @variable |
