VS Code and Metals: Run 'Build import' to enable code navigation

1.9k views Asked by At

I have a Scala- / Mill-Project that I wan't to import into VSCode.

The Metals Doctor gives me the following warnings:

Metals Doctor image

Is there something missing in my project?

Here is my Mill configuration (build.sc):

import mill._
import mill.define.Target
import scalalib._

trait MyModule extends ScalaModule {
  def scalaVersion = "2.13.1"

  object version {
    val cats = "2.0.0"
    ..
  }

  object libs {
    val cats = ivy"org.typelevel::cats-core:${version.cats}"
    ..
  }

  object test extends Tests {
    ...
  }

}

object entity extends MyModule {
  override def ivyDeps = {
    Agg(
      libs.cats,
      ..
    )
  }
}

object macros extends MyModule {
..
}

Here is the whole project: https://github.com/pme123/zio-examples

The console output shows no warnings, here is the end:

...
time: connected to build server in 0.33s
time: imported build in 0.41s
time: indexed workspace in 3.85s
no build target: /Users/mpa/dev/Github/pme123/zio-examples/build.sc
1

There are 1 answers

0
Tobias Roeser On

This error/help message is misleading, as it presumes you are using Bloop, in which case re-importing solves the isssue (from experience). When you are using Mill's built-in BSP server, this won't change much.

Mill's recent 0.10.0-M4 release got a major BSP revamp. Also Metals improved it's Mill support. So you should have a better overall experience.

Here is some documentation: https://com-lihaoyi.github.io/mill/mill/Intro_to_Mill.html#_build_server_protocol_bsp