Commit Graph

36 Commits (599d12b59fed092f5a3d4a7019fd85d90cb39ec1)

Author SHA1 Message Date
Eugene Yokota a6e8f24623 Move corpus
**Problem/Solution**
I noticed that corpus tests weren't running.
Apparently tree-sitter 0.22.0 moved the directory -https://github.com/tree-sitter/tree-sitter/releases/tag/v0.22.0
2024-06-30 17:52:41 +07:00
Eugene Yokota 7dd646ff64 Refactor highlighting
tree-sitter now uses last-wins rules for highlighting.
This moves the rules around to match the older highlighting.
Except operator, which I've now let it take precedence over `function.call`.
2024-03-12 03:05:12 +07:00
susliko f8d3848919 Fix parenthesized expressions in braceless `if` conditions
Fixes #263 and #342
`_if_condition` extracted from `if_expression` and given a magic dynamic
precedence of 4
2023-09-18 21:48:31 +07:00
Amaan Qureshi dffe55e73c
fix(scanner): compiler warnings, lints, mark helper functions static & refactor word-reading logic 2023-08-17 23:22:01 +07:00
Johannes Coetzee 6f9683bbfb Handle quote dollar escape case as well 2023-07-21 10:01:38 +07:00
Johannes Coetzee f894d1d0cd Add highlighting test 2023-07-20 18:47:29 +07:00
Natsu Kagami 25f8fdfb74
Change wrong scala3 test
Old test used to pass due to `lua-match` predicates not being run with `tree-sitter` command
2023-06-30 15:35:53 +07:00
Domas Poliakas e0b4206942 Added block comments to the comment highlighting query 2023-06-06 11:55:23 +07:00
susliko 5da643806c Support Scala CLI using directives
Summary
-------
Single line `$.comment` is split into a choice of `$._comment_text` and
`$.using_directive` to parse a structure of comments like
```
//> using scala 3.3.0
```
2023-05-31 23:04:52 +07:00
Eugene Yokota fa6ffa149f Add more highlight test 2023-05-26 11:02:37 +07:00
Eugene Yokota e292682508 Match type
This implements support for Scala 3 match types.
2023-05-26 10:18:32 +07:00
Kasper Kondzielski 7d348f51e4
fix: Incorrect string interpolation highlighting group (#196)
* fix: Incorrect string interpolation highlighting group

Co-authored-by: ghostbuster91 <ghostbuster91@users.noreply.github.com>
2023-03-15 22:28:35 +07:00
Chris Kipp 8c11afe211 refactor(queries): change uppercase from constant to type
This is in reference to the conversation that was in
https://github.com/tree-sitter/tree-sitter-scala/discussions/168 around
imports and the coloring of the final part. Taken from Eugene's comment,
which made a lot of sense to message

> In Scala we have namespace for terms and types, and they can each
> define the same name, often encouraged as "companion object", so at the
> point of import statement it's ambiguous.

This is relevant in the import case, but I also think I agree with it
most of the time when you have an uppercase identifier. While there may
be times this isn't the case, I think it's a safe default.
2023-01-20 16:51:17 +07:00
Chris Kipp 65316edadd test: just a few more highlight tests
I was confirming a couple things locally so figured
I'd just push these up.
2023-01-18 12:32:17 +07:00
Chris Kipp 71b408eed0 feat: add an explicit interpolator field
_The problem_

Currently when you come across string interpolation you don't get any
special highlighting for the actual interpolator meaning:

```scala
ivy"com.lihaoyi::os-lib:0.9.0"
```

I all colored the same.

_The Solution_

The pr makes 2 changes.

- The `identifier` we use for the interpolator now becomes a field for
  no reason other than I thought it'd be nice to just give it a name
- A hightlight query that captures it and assigns it to `function.call`.
2023-01-18 08:21:39 +07:00
Eugene Yokota 31aba1de6e Fixes buffer overrun
Problem
-------
The buffer given for payload serialization is 1024,
but we are currently using (1024 + 3) * sizeof(int)

Solution
--------
Reduce it way down, and fix a few things around unsigned vs int
2023-01-17 00:19:03 +07:00
Chris Kipp b49a1fca34
chore: sync highlights back with nvim-treesitter (#148) 2023-01-15 11:16:57 +07:00
Eugene Yokota 00cfe78f27 Add tests for optional braces highlights
Fixes https://github.com/tree-sitter/tree-sitter-scala/issues/59
2023-01-13 15:04:49 +07:00
eugene yokota c110fbaece
Merge pull request #128 from eed3si9n/wip/fewer_braces
SIP-44 Fewer braces support
2023-01-12 14:36:28 +07:00
eugene yokota 5991810787
Merge pull request #130 from ghostbuster91/structural-types-2
Add support for structural types
2023-01-12 13:54:45 +07:00
ghostbuster91 bfa99af075 Add highlight tests for structural types 2023-01-12 19:10:06 +07:00
Eugene Yokota a5ee1d6053 Use storageclass
Problem
-------
Currently storage related modifiers use keyword.

Solution
--------
We should use `storageclass` for `private`, `protected`, and `inline`.
See also https://www.sublimetext.com/docs/scope_naming.html#storage

> Keywords that affect the storage of a variable, function or data structure should use the following scope. Examples include static, inline, const, public and private.
2023-01-12 11:34:30 +07:00
Eugene Yokota 710e5cccc5 Add the val y = x: Int example 2023-01-12 10:45:32 +07:00
Eugene Yokota ffcbfc90a9 SIP-44 Fewer braces support
Fixes https://github.com/tree-sitter/tree-sitter-scala/issues/127

Problem
-------
Currently our grammar does not support the fewer braces syntax,
which basically lets us pass the last argument as a block after `:`.

Solution
--------
This implements fewer braces support for call_expression,
infix_expression, with and without the lambda start.
2023-01-12 10:45:32 +07:00
Eugene Yokota 77ea27edbe Fixes instance_expression
Problem
-------
Current grammar accepts expression immeidately after `new`,
which is not correct, and doesn't work for Scala 3 syntax.

Solution
--------
This fixes it by actually using `$.template_body`.
It does create a tricky conflict between `new A: <block>`
construct and `new A: <type>`.
To deal with that, we are using `prec.dynamic`.
2023-01-11 19:15:42 +07:00
Anton Sviridov 94b7758931 Export clauses 2023-01-10 10:34:18 +07:00
Anton Sviridov cbf8207f4c
Extra highlights for scala 3 constructs (#120) 2023-01-10 09:59:00 +07:00
Anton Sviridov 6120785552
Transparent, open, infix (#119) 2023-01-10 09:03:36 +07:00
Eugene Yokota bf4102c863 Include operator-like identifier as simple expression
Problem
-------
Currently operator-like identifiers are not part of the simple
expression, so you can't call `::(123)`.

Solution
--------
This includes `$.operator_identifier` into `_simple_expression`,
and further improves the expression hierarchy.

Note that this removes test on double-prefix-expression.
It's not allowed in Scala spec to have double-prefix.
2023-01-09 18:54:50 +07:00
Anton Sviridov 80cb5ed88f Inline def, if, given, match 2023-01-09 22:48:08 +07:00
Anton Sviridov f05407f2f6 Scala 3 enums: fix simple case inheritance 2023-01-09 21:43:23 +07:00
Eugene Yokota d6fc64c43b Add hightlight test for self type 2023-01-09 14:44:31 +07:00
Anton Sviridov c69a3eccc8 Update query highlights and add tests 2023-01-08 13:42:33 +07:00
Eugene Yokota 1e70f7de9e Fix indent/outdent tracking, part 2
Problem
-------
Given something like
  class A:
    def l: Int =
      1

    def m = ()
the scanner doesn't inject automatic semicolon since the newline
has been consumed by outdenting, and it fails to parse the code.

Solution
--------
Track `last_newline_count` in the payload, which represents the
newline_count at the time out outdent.
This then is recovered so automatic semicolon can use it
only if the column position hasn't moved.
2022-12-20 11:38:51 +07:00
Eugene Yokota 83aaa6020e Fix indent/outdent tracking
Problem
-------
Given something like
    class A:
      def a() =
        ()

    def a() = 1
the scanner only outdents once, so it fails to parse the above.

Solution
--------
Track `last_indentation_size` in the payload to indicate last
outdent (default: -1). If it's not -1 that means there was an outdent.
This then checks if the last_indentation_size qualified for another
outdent.
2022-12-20 11:38:50 +07:00
Anton Sviridov 0002b5f094 Indent/Outdent external parser 2022-12-15 13:09:29 +07:00