[Scala] Add support for Scala 3
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.
According to https://dotty.epfl.ch/docs/reference/syntax.html it looks like a good candidate for SBNF (see: https://lib.rs/crates/sbnf)
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.
Update: Scala 3 was released today
Any updates on this? Would be super nice to have some updated syntax highlight for Scala3!
BTW the syntax doc have been moved to https://docs.scala-lang.org/scala3/reference/syntax.html
Would love to get support for Scala3. If I can assist in any way, I'd be happy to. 👍
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
PR? We only have this feature request issue, atm.
Would need some Scala guy with ST syntax knowledge to contribute.
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.
Hi @djspiewak is this is still on your radar ?
@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. 🙂
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!
See also:
- https://github.com/sublimehq/Packages/issues/588