Packages icon indicating copy to clipboard operation
Packages copied to clipboard

[Scala] Add support for Scala 3

Open djspiewak opened this issue 4 years ago • 13 comments

Scala 3 is currently in its final release candidate, and a release is expected within about a month. While the existing syntax mode does work just fine for the subset of Scala 3 which overlaps with Scala 2, there are a large number of constructs which have been added to the language which are not fully supported. A non-exhaustive list follows:

  • given, then, as, and similar new keywords (most of which are "soft" keywords that only parse as such in the proper context)
  • Significant indentation (similar to Python; has a major impact on auto-indentation hints)
  • New class definition syntax (related to the above)
  • Mix-fix method definition syntax
  • Higher-rank types (e.g. [A] =>> (A, A => Int) => Int)
  • Context-bounds included within types (e.g. Monoid[A] ?=> (A, A) => A)
  • New meaning for wildcards (e.g. * in imports, ? in types, etc)
  • New macro syntaxes (related to the new keywords problem)

The list goes on. There's a lot of stuff to update here. I plan to get to this eventually, but my calendar is a bit crunchy right now, so I'm putting this issue out here so that others can be aware of the need.

djspiewak avatar Apr 24 '21 19:04 djspiewak

According to https://dotty.epfl.ch/docs/reference/syntax.html it looks like a good candidate for SBNF (see: https://lib.rs/crates/sbnf)

deathaxe avatar May 01 '21 14:05 deathaxe

Maybe! I sincerely doubt though that the reference you linked is definitive. The Scala 3 parser is hand-written. Also the whitespace-sensitivity is not well captured by the core grammar.

djspiewak avatar May 01 '21 21:05 djspiewak

Update: Scala 3 was released today

djspiewak avatar May 13 '21 15:05 djspiewak

Any updates on this? Would be super nice to have some updated syntax highlight for Scala3!

thewchan avatar Jul 16 '21 01:07 thewchan

BTW the syntax doc have been moved to https://docs.scala-lang.org/scala3/reference/syntax.html

ayoub-benali avatar Nov 15 '21 19:11 ayoub-benali

Would love to get support for Scala3. If I can assist in any way, I'd be happy to. 👍

hovsater avatar Apr 27 '22 19:04 hovsater

Would love to get support for Scala3. If I can assist in any way, I'd be happy to. 👍

~~@kevinsjoberg Use this PR by following the ReadMe instructions and checking out this branch (or code that includes it), and then endorse or comment.~~ Oops

michaelblyons avatar Apr 28 '22 16:04 michaelblyons

PR? We only have this feature request issue, atm.

Would need some Scala guy with ST syntax knowledge to contribute.

deathaxe avatar Apr 28 '22 16:04 deathaxe

My mistake. I looked at the first post and saw the list of things to do and imagined it was a list of thing that were done. 😊 Did not look at the Issue/PR icon at all or the fact that there was no tab for file changes.

michaelblyons avatar Apr 28 '22 16:04 michaelblyons

Hi @djspiewak is this is still on your radar ?

ayoub-benali avatar Jun 08 '22 07:06 ayoub-benali

@djspiewak I'd be happy to put some money into getting the Scala syntax updated if you're up for it. Feel free to reach out if you're interested. 🙂

hovsater avatar Apr 29 '23 06:04 hovsater

I took some time to modify the default syntax highlighting and add support for some of the new Scala 3 syntax/keywords. My repo is at https://github.com/mrdziuban/sublime-scala-3-syntax, and you can see a diff of the Scala.sublime-syntax file here: https://github.com/mrdziuban/sublime-scala-3-syntax/compare/base-build-4169...upd-build-4169

It's far from complete, but even just having the new keywords highlighted and having enums be included when I search for symbols has been really nice. I don't plan to add support for significant indentation/optional braces, but I'm definitely open to contributions or forks!

mrdziuban avatar Feb 26 '24 13:02 mrdziuban

See also:

  • https://github.com/sublimehq/Packages/issues/588

hovsater avatar Jul 23 '24 06:07 hovsater