Commit graph

39 commits

Author SHA1 Message Date
Amaan Qureshi
584d96b46b fix(scala): remove unused rule 2024-10-16 08:35:54 +02:00
Omar Valdez
188b1a6d01
feat(highlights): capture wildcard patterns as @character.special (#7153) 2024-09-20 08:15:01 +02:00
Omar Valdez
d13f0183ba
feat(highlights): capture wildcard imports as @character.special 2024-08-01 10:24:40 +02:00
Riley Bruins
c911f19d91 feat(scala): add some missing highlights 2024-06-15 13:03:22 -04:00
Riley Bruins
f58cae6c22 feat: more @keyword.type captures 2024-05-01 09:59:50 +02:00
Phạm Huy Hoàng
722617e672 refactor(format): drop extra indentation for field 2024-03-21 15:51:26 +01:00
Jaehwang Jung
dccf31f9b1 feat(highlights)!: @keyword.storage@keyword.modifier 2024-03-16 20:51:16 +08:00
Jaehwang Jung
998b230a77 feat(highlights)!: keyword @type.qualifier@keyword.modifier 2024-03-16 20:51:16 +08:00
Phạm Huy Hoàng
77e298e4de chore: format queries 2024-01-21 23:55:02 +09:00
ObserverOfTime
fa38f4e6f9 fix(highlights): improve member/property distinction 2024-01-19 16:58:37 +01:00
ObserverOfTime
2f38c36294 fix(highlights): improve consistency 2024-01-19 16:58:37 +01:00
Pham Huy Hoang
57a8acf0c4 chore: query formatting 2024-01-19 16:58:37 +01:00
Christian Clason
1ae9b0e455 feat!: align standard captures with upstream
Problem: Sharing highlight queries with upstream tree-sitter and
Helix is difficult.

Solution: Where reasonable, use capture names in tree-sitter's standard
list or Helix's Atom-style hierarchy.

Specifically:

* tree-sitter "standard capture names"
  (3f44b89685/highlight/src/lib.rs (L20-L72)):

  - `@parameter` -> `@variable.parameter`
  - `@field` -> `@variable.member`
  - `@namespace` -> `@module`
  - `@float` -> `@number.float`
  - `@symbol` -> `@string.special.symbol`
  - `@string.regex` -> `@string.regexp`
  - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below)
  - `@text.title` -> `@markup.heading`
  - `@text.literal` -> `@markup.raw`
  - `@text.reference` -> `@markup.link`
  - `@text.uri` -> `@markup.link.url` (in markup links)
  - `@string.special` -> `@markup.link.label` (non-url links)
  - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`)

* Helix captures
  (https://docs.helix-editor.com/master/themes.html#syntax-highlighting):

  - `@method` -> `@function.method`
  - `@method.call` -> `@function.method.call`
  - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}`
  - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}`
  - `@text.uri` -> `@string.special.url` (outside markup)
  - `@preproc` -> `@keyword.directive`
  - `@define` -> `@keyword.directive`(`.define`?)
  - `@storageclass` -> `@keyword.storage`
  - `@conditional` -> `@keyword.conditional`
  - `@debug` -> `@keyword.debug`
  - `@exception` -> `@keyword.exception`
  - `@include` -> `@keyword.import`
  - `@repeat` -> `@keyword.repeat`

* cleanup

  - remove some redundant `@conceal` (but still allow it for conceal-only patterns)
  - remove obsolete `@error` (syntax linting is out of scope for this repo)
  - sort, cleanup capture list in `CONTRIBUTING.md`
2024-01-19 16:58:37 +01:00
Christian Clason
5b90ea2aba feat(locals)!: switch to upstream captures 2024-01-19 16:58:37 +01:00
Robert Jackson
4c9da29cbd
fix(scala): add for_expression locals
This change does two main things:

1. Indicate that `(for_expression)`'s introduce a `@scope` (this
   is the scope for the enumerators to be used within the loop).
2. Indicate that the `(identifiers)` within the `(enumerators)` are
   `@definition.var`s.

---

For the following example snippet:

```scala
val fruits = List("apple", "banana", "avocado", "papaya")

val countsToFruits = fruits.groupBy(fruit => fruit.count(_ == 'a'))

for ((count, fruits) <- countsToFruits) {
  println(s"with (fruits) 'a' × $count = $fruits")
}
```

The `count` and `fruits` identifiers are new definitions introduced by
the `for` expressions scope.
2023-10-15 18:43:34 +00:00
Robert Jackson
dba7d120e5
fix(scala): ensure function_definition is in parent scope 2023-10-15 18:40:36 +00:00
Robert Jackson
262e9b1e86 fix(scala): Mark (lambda_expression) without bindings as @defintition.parameters
When you have a lambda expression like:

```scala
val fruits = List("apple", "banana", "avocado", "papaya")

val countsToFruits = fruits.groupBy(fruit => fruit.count(_ == 'a'))

for ((count, fruits) <- countsToFruits) {
  println(s"with (fruits) 'a' × $count = $fruits")
}
```

The `fruit => fruit.count(_ == 'a')` lambda expression (note: without
wrapping parenthesis) does not create a `(binding)` node. Its syntax
tree is:

```
    (lambda_expression) ; [5:18 - 47]
     parameters: (identifier) ; [5:18 - 22]
     (call_expression) ; [5:27 - 47]
      function: (field_expression) ; [5:27 - 37]
       value: (identifier) ; [5:27 - 31]
       field: (identifier) ; [5:33 - 37]
      arguments: (arguments) ; [5:38 - 47]
       (infix_expression) ; [5:39 - 46]
        left: (wildcard) ; [5:39 - 39]
        operator: (operator_identifier) ; [5:41 - 42]
        right: (character_literal) ; [5:44 - 46]
```

That example just _happens_ to be **exactly** one of the example from
https://www.scala-lang.org/ ([see
playground](https://scastie.scala-lang.org/S0bkCiXkQiuOMXnlhWn46g)) 😁.
2023-10-15 14:33:21 -04:00
Pham Huy Hoang
78b54eb7f6 chore(injections)!: update injection syntax to 0.9
Since 0.9, @lang syntax is still available as fallback but will soon be deprecated.
Because of that, new syntax should be adopted once 0.9 becomes the
baseline requirements for nvim-treesitter

- update health check
- update doc
2023-08-12 17:34:15 +02:00
Chris Kipp
5944fc821a
feat(scala): sync highlights with latest upstream (#4926)
This accounts for a correction in interpolations and also adding support
for `self_type`.

This is a follow-up to #4920.
2023-06-09 10:15:06 +02:00
Domas Poliakas
ab3bf7d956
fix(scala): add block_comment 2023-06-06 14:36:09 +00:00
Chris Kipp
2cbe8a4296
highlights(scala): add support for using directives (#4893)
This accounts for the updates in https://github.com/tree-sitter/tree-sitter-scala/pull/273.
2023-06-02 22:13:30 +09:00
Kasper Kondzielski
ee64345a37 fix: Correct scope definition for scala
`@scope` included `function_declaration` while is should have included `function_definition` instead. The former one is used to declare abstract functions while the latter one is used to define functions together with their bodies.
2023-04-28 00:34:23 +02:00
ghostbuster91
06075ecd04 fix(scala): Add missing locals definitions for scala 2023-04-01 14:29:43 -04:00
Chris Kipp
25dd24ed0e feat(scala): add in local variables queries
This syncs the queries that were updated in https://github.com/tree-sitter/tree-sitter-scala/pull/196.

Co-authored-by: ghostbuster91 <ghostbuster91@users.noreply.github.com>
2023-03-27 06:48:21 -04:00
Amaan Qureshi
5a87bc98da feat: add @comment.documentation where applicable 2023-03-05 17:15:32 -05:00
Chris Kipp
a943661be8 refactor(scala): update scala highlights for uppercase identifiers
This is a small change that comes from the discussion we had in
https://github.com/tree-sitter/tree-sitter-scala/discussions/168#discussioncomment-4718624.
The idea here is that we're sort of making an assumption on what an
uppercase identifier is in Scala and more times than not, it's actually
a `@type`. So this changes the `@constant` capture to a `@type` one. You
can find the full context in the linked discussion.
2023-01-21 17:59:30 +01:00
Chris Kipp
28aa6ba554
scala: add interpolator query (#4175) 2023-01-18 12:06:32 +01:00
Chris Kipp
1c89f9b5bc sync with latest Scala and add binding 2023-01-15 09:46:06 -08:00
Chris Kipp
add6f9abe2 refactor(scala): update the Scala highlight queries
There has been a lot of changes recently to the Scala grammar and we've
been merging in a handful of things before syncing the actual generated
parser. We are currently at a stage where we're going to sync
everything, but there are some breaking changes that are included in
https://github.com/tree-sitter/tree-sitter-scala/pull/135, so when that
commit gets synced here stuff will break. We've taken the queries that
existed here and have been building off of them in the actual upstream
repo. This will hopefully make the transition smooth and updates the
queries to ensure that there is no breakage. It's recommended to wait
until that pr is merged, synced here, and then merge this in around the
same time.

Co-authored-by: eugene yokota <eed3si9n@gmail.com>
Co-authored-by: Anton Sviridov <keynmol@gmail.com>
2023-01-14 12:56:56 -08:00
ObserverOfTime
abd7f85040 highlights(scala): use more specific groups 2022-11-26 13:17:51 +02:00
Lewis Russell
37398c7d68 feat(spell): support more languages 2022-09-26 13:47:12 +01:00
lfenzo
c784720917 Split func/method definition from calls in several programming language queries 2022-08-03 12:05:30 -07:00
Lewis Russell
011ac894ec Prefer lua-match over match
as string.find is much quicker than vim.regex:match*
2021-11-23 10:02:06 +01:00
Dundar Göc
6a4fdb317d chore: fix typos 2021-11-02 23:47:48 +01:00
Stevan Milic
ea0f6614b7 Add scala maintainer
Add fold for scala val definition to support type class entries
2021-10-07 23:24:45 +02:00
Stevan Milic
8c105dedec Add scala folds 2021-09-04 04:36:30 +02:00
Stevan Milic
59f881fff8 Update scala highlights
* add highlights for imports

* add highlights for type constructors

* add highlights for constants

* add highlights for interpolation string

* add highlights for comments through injection
2021-09-04 04:36:30 +02:00
Stevan Milic
a90e5f4c5f
update scala highlights (#1760)
* add type highlights

* add call expression highlights

* add function definition highlights

* add expression highlights

* add literals highlights

* add operator highlights

* add punctuation highlights

* add comment highlights

Co-authored-by: Stevan Milic <stevan.milic@tradecore.com>
2021-08-28 14:07:44 -05:00
Stuart Mashaal
4f2265632b
add keywords to scala highlights (#1662)
* add keywords to scala highlights

* special capture for special keywords

* add while to 'repeat' capture

* pr cleanup, exmaples in CONTRIBUTING.md

* add backquotes for consistency in docs

* group @repeat keywords, fix null

* comment-out 'macro' and 'forSome'

* fix 'this' and 'super' keyword

* remove accidental files 🤦

* update revision

* fix "super" and "this"

* godammit these .metals files are killing me

* why did I commit this???

Co-authored-by: Stuart Mashaal <smashaal@hopper.com>
2021-08-25 18:38:45 -05:00