Metals
your IDE FOR SCALA 3
Tomasz Godzik
Agenda
1. Introduction
2. BASIC FEATURES.
3. GETTING STARTED WITH SCALA 3
4. Demo
5. Advanced features
6. BSP AND LSP
7. Recent work
8. Upcoming work
9. Questions!
Questions!
Please ask in the Q&A!
Will try to answer all at the end.
Why am I Here?

Why am I Here?


Why am I Here?


Why am I Here?

Currently working on Metals as one of the main contributors as a part of the collaboration between VirtusLab and Scala Center.


Who Contributed to what metals is today?

Metals - Scala (3) language server with rich ide features


Your favourite language in you favourite Editor





tooling
- Scala is not just the compiler
- it's the whole tooling ecosystem
- Proper IDE is important for users to pick up the language
Tooling
- coordinating efforts with the compiler team
- each Scala 3 compiler release is synced with Metals
- upstream fixes to the compiler

Scala 3 support
- Based on Dotty language server
- evolved heavily since then
- we still depends on the compiler itself

completions
most of the existing functionality on par with Scala 2
Improved with each release

hover
information shown when mouse over symbol
additional Scala 3 specific info - extension methods and enums

Definition
uses information from semanticdb generated during compilation
fallback uses the compiler

References
uses semanticdb
needs compilation
responsive

Renames
uses semanticdb
needs compilation
will rename all symbol overrides

GET STARTED WITH scala3
Via coursier
> cs install giter8
> g8 scala/scala3.g8
> cd dotty
> code .VIA NEW PROJECT WIZARD

GET STARTED WITH scala 3
New CLI tool to work with Scala
Not only 3!
Support for Native and JS
Seamless, friction less experience
DEMO!

in an online IDE
1. go to https://GITHUB.COM/TGODZIK/CREATIVE-SCALA
2. Click on the first link available
or
Just use the ready link:
https://gitpod.io/#https://github.com/tgodzik/creative-scala
in an online IDE
You can also join me in my workspace!
https://indigo-ptarmigan-67ssord3.ws-eu17.gitpod.io
Let's try to use doodle to create a shape mosaic from all the people

Advanced features
run/debug
run and debug your scala 3 programs
you can use the new @main annotation
via lenses, launch.json or special commands
EXPRESSION EVALUATION STILL WORKED ON

Pasting code
automatically fix indentation when copy pasting
based on the current indentation at paste
additional setting
metals.enableIndentOnPaste
still experimental

scalafmt support
metals will automatically set up .scalafmt.conf file
it will make sure a proper dialect is used for each source root
always most recent version
version = "3.0.5"
runner.dialect = scala212
fileOverride {
"glob:**/tests/input3/src/main/scala/**" {
runner.dialect = scala3
}
"glob:**/mtags/target/target3/scala-3.1.0/src_managed/main/**" {
runner.dialect = scala3
}
"glob:**/mtags/src/main/scala-3/**" {
runner.dialect = scala3
}
}
Organize imports
works for all Scala 3 code except given imports
fix available in the next release
works with unsaved code
can be configured to work on CI
works with defaults
no unused imports

Additional decorations
Starting with 3.1.0 -> type decorations!
can be turned on via toggle or in settings
great work by Rikito Taniguchi in the compiler

source file analyzer
Different ways to view your Scala files:
- javap
- semanticdb
- tasty
- soon java decompiler

worksheets
- allow you to quickly experiment with the language and workspace
- can work with source or totally independently
- powered by mdoc

The language server protocol
How does it work
Client Editor


LSP Server
How does it work
Client Editor


LSP Server
object Main{
def adding(a : Int, b : Int) = a + b
val additional = ""
val one = 1
val two = 2
addi_
}How does it work
Client Editor


LSP Server
Completions
object Main{
def adding(a : Int, b : Int) = a + b
val additional = ""
val one = 1
val two = 2
addi_
}How does it work
Client Editor


LSP Server
Completions
object Main{
def adding(a : Int, b : Int) = a + b
val additional = ""
val one = 1
val two = 2
addi_
}How does it work
Client Editor


LSP Server
object Main{
def adding(a : Int, b : Int) = a + b
val additional = ""
val one = 1
val two = 2
addi_
}How does it work
Client Editor


LSP Server
- adding()
- additional
object Main{
def adding(a : Int, b : Int) = a + b
val additional = ""
val one = 1
val two = 2
addi_
}How does it work
Client Editor


LSP Server
- adding()
- additional
object Main{
def adding(a : Int, b : Int) = a + b
val additional = ""
val one = 1
val two = 2
addi_
}How does it work
Client Editor


LSP Server

object Main{
def adding(a : Int, b : Int) = a + b
val additional = ""
val one = 1
val two = 2
addi_
}How does it work
Client Editor


LSP Server
object Main{
def adding(a : Int, b : Int) = a + b
val additional = ""
val one = 1
val two = 2
adding(_)
}The build server protocol


The universe of Build tools
Mill



The universe of Build tools
Mill




Metals
The universe of Build tools
Mill



Metals



- can generate configuration files for Bloop Build server
- standalone server
- supports Scala 3
Mill

- can generate configuration files for Bloop Build server
- standalone server
- SUPPORTS SCALA 3


- can generate configuration files for Bloop Build server
- SUPPORTS SCALA 3


- can generate configuration files for Bloop Build server
- SUPPORTS SCALA 3 from 7.3 version

BSP Server

LSP Server
How does it work?

BSP Server

LSP Server
What is this code a part of!

How does it work?

BSP Server

LSP Server
Which project?
How does it work?

BSP Server

LSP Server
Which project?
How does it work?

BSP Server

LSP Server
How does it work?

BSP Server

LSP Server
Project Foo
How does it work?

BSP Server

LSP Server
Project Foo
How does it work?

BSP Server

LSP Server
I don't know how to compile it!

How does it work?

BSP Server

LSP Server
Compile Foo!
How does it work?

BSP Server

LSP Server
Compile Foo!
How does it work?

BSP Server

LSP Server
How does it work?

BSP Server

LSP Server
Error report
How does it work?

BSP Server

LSP Server
Error report
How does it work?

BSP Server

LSP Server
Diagnostics
How does it work?
Recent Work
- expression evaluator (Scala 3 coming later)
- type on selection
- search text files in jars
- continuous Scala 3 improvements
NEWEST Metals FEATURES

NEWEST Metals FEATURES
Quick look

What do we need to work on
Custom Completions
new Scala 3 specific completions
Expression evaluator for debugging
Some of the refactorings including `Implement all members`

Don't hestitate to sent us ideas

We do listen!

Scala Days talk by Ólafur Páll Geirsson: https://tinyurl.com/metals-scala
Great in-depth explanation by Chris Kipp: https://tinyurl.com/metals-explained
Metals in vim
https://tinyurl.com/metals-vim
Intro to working with metals
https://tinyurl.com/metals-intro
Related Talks
Presentation: https://slides.com/tomekgodzik/scala3-ide
Metals documentation: https://scalameta.org/metals/
Bloop documentation: https://scalacenter.github.io/bloop/
Reach out to me on Twitter: @TomekGodzik
OR
Ask me about anything on gitter/discord!
QUESTIONS?
Metals - your IDE for Scala 3
By Tomek Godzik
Metals - your IDE for Scala 3
- 476