IDE Support

To support various IDEs and Language Servers, Mill supports the Build Server Protocol in version 2.1.0-M4 and has a built-in BSP server.

In addition to BSP, Mill also supports IntelliJ IDEA project configuration generation directly.

Build Server Protocol (BSP)

The Build Server Protocol has the concept of BSP server discovery, which means: A BSP client can connect to any BSP server, as long as there is a connection file under the .bsp/ directory.

To install a BSP connection file .bsp/mill-bsp.json for Mill, run:

mill mill.bsp.BSP/install

Working known clients of the BSP server are IntelliJ IDEA and Metals.

You can fine control some BSP server options by specifying command options:



--jobs n

Use n threads in parallel to run tasks. A value of 0 means to use as many threads as the system has cpu cores.

Using Metals

When using Metals by default Bloop will be used as your build server unless you explicitly choose Mill. When in a Mill workspace use the "Switch Build Server" command from Metals which will allow you to switch to using Mill as your build server. If no .bsp/mill-bsp.json file exists, Metals will automatically create it for you and then connect to Mill.

Metals is relying on SemanticDB to enable many of its features. Mill BSP now also supports to provide this SemanticDB data, when the BSP client (like Metals) requests it.

As of writing this, Metals 0.11.8 is the latest available version, which is not able to detect the fact, that Mill is already providing SemanticDB data. As a consequence, it reports missing SemanticDB data, although some SemanticDB-based features are already working. This may be fixed eventually in a future release of Metals.

Updating older setups

In the past, we provided SemanticDB support via mill.scalalib.bsp.ScalaMetalsSupport trait, which had to be mixed-in to your Scala modules. This is no longer needed and deprecated. You should remove these mix-ins. ScalaMetalsSupport trait is now deprecated and will be removed in the future.

If things go wrong

In case things go wrong, it can be sometimes hard to find the cause. BSP is just a protocol, and as such, issues on the server side (the Mill BSP server) might not well propagated to the BSP client (your IDE).

For that reason Mill BSP server is writing a log file under .bsp/mill-bsp.stderr, where you can find various information about what’s going on. Its content should look familiar, as it contains regular Mill output accompanied by additional BSP client-server communication details.

You can increase the verbosity of that log file, when you run Mill with --debug at installation time (of the BSP discovery file).

mill --debug mill.bsp.BSP/install

Using Bloop (standalone BSP server)

If you wish to use Bloop as your build server (it is the default metals BSP implementation) with metals / vscode, consider using the mill bloop plugin.

This is preferred to the instructions (currently) on the bloop website.

Please be aware, that the Bloop contrib plugin is maintained by the community and is probably not on a par with the built-in BSP server.

IntelliJ IDEA Support

IntelliJ IDEA also supports the BSP protocol. To use this support, just follow the directions in Build Server Protocol (BSP).

Additionally, you can generate IDEA project files directly with Mill. This is probably the preferred way if you work on polyglot projects and need support for other languages like Kotlin or AspectJ.

To generate IntelliJ IDEA project files into .idea/, run:

mill mill.scalalib.GenIdea/idea