VSCode setup
Scala CLI can generate the files that are necessary for providing IDE support in Visual Studio Code.
For example, here is a simple project in scala-cli which contains only one main and one test class.
@main
def hello() = println("Hello, world")
//> using dep org.scalameta::munit::1.0.0-M1
class MyTests extends munit.FunSuite {
test("test") {
val x = 2
assertEquals(x, 2)
}
}
The following command generates configuration files for VSCode support:
scala-cli setup-ide .
There is also another way. The first time you run the run
|compile
|test
commands, the configuration files for the
VSCode will be also generated.
scala-cli run .
# "Hello, world"
and then, we launch Visual Studio Code
code .
After starting metals, you will see the run/debug
buttons in HelloWorld.scala
and test/debug
in MyTests.test.scala
(assuming the following directory layout).
Pressing the run
button will run the Main.scala
, the output will be visible in DebugConsole
.
![](/assets/images/vscode-run-b7c05071cc98cb3dc8d8e305ea22b29d.png)
And the similar effect after pressing the test
button.
![](/assets/images/vscode-test-c56e6bf70fcc9d1410bd952ee6843ca4.png)