|
1 |
| -package mill.contrib |
| 1 | +package mill |
2 | 2 |
|
| 3 | +import ch.epfl.scala.bsp4j.BuildClient |
3 | 4 | import java.io.PrintWriter
|
4 | 5 | import java.nio.file.FileAlreadyExistsException
|
5 | 6 | import java.util.concurrent.Executors
|
6 |
| -import ch.epfl.scala.bsp4j._ |
7 |
| -import mill._ |
8 |
| -import mill.contrib.bsp.MillBuildServer |
| 7 | +import mill.bsp.{BspConfigJson, MillBuildServer} |
9 | 8 | import mill.define.{Command, Discover, ExternalModule}
|
10 | 9 | import mill.eval.Evaluator
|
11 | 10 | import mill.modules.Util
|
12 | 11 | import org.eclipse.lsp4j.jsonrpc.Launcher
|
13 |
| -import upickle.default._ |
14 |
| -import scala.collection.JavaConverters._ |
15 | 12 | import scala.concurrent.CancellationException
|
16 |
| -import scala.util.Try |
17 |
| - |
18 |
| -case class BspConfigJson( |
19 |
| - name: String, |
20 |
| - argv: Seq[String], |
21 |
| - millVersion: String, |
22 |
| - bspVersion: String, |
23 |
| - languages: Seq[String] |
24 |
| -) extends BspConnectionDetails(name, argv.asJava, millVersion, bspVersion, languages.asJava) |
25 |
| - |
26 |
| -object BspConfigJson { |
27 |
| - implicit val rw: ReadWriter[BspConfigJson] = macroRW |
28 |
| -} |
| 13 | +import upickle.default.write |
29 | 14 |
|
30 | 15 | object BSP extends ExternalModule {
|
31 |
| - |
32 | 16 | implicit def millScoptEvaluatorReads[T] = new mill.main.EvaluatorScopt[T]()
|
33 | 17 |
|
34 |
| - lazy val millDiscover: Discover[BSP.this.type] = Discover[this.type] |
| 18 | + lazy val millDiscover: Discover[this.type] = Discover[this.type] |
35 | 19 | val bspProtocolVersion = "2.0.0"
|
36 | 20 | val languages = Seq("scala", "java")
|
37 | 21 |
|
@@ -73,15 +57,16 @@ object BSP extends ExternalModule {
|
73 | 57 | def createBspConnectionJson(): String = {
|
74 | 58 | val millPath = sys.props
|
75 | 59 | .get("java.class.path")
|
76 |
| - .getOrElse(throw new IllegalStateException("System property java.class.path not set")) |
| 60 | + .getOrElse(throw new IllegalStateException( |
| 61 | + "System property java.class.path not set")) |
77 | 62 |
|
78 | 63 | write(
|
79 | 64 | BspConfigJson(
|
80 | 65 | "mill-bsp",
|
81 | 66 | Seq(
|
82 | 67 | "sh",
|
83 | 68 | "-c",
|
84 |
| - s"env ${sys.env.map { case (k, v) => s""""$k=$v"""" }.toSeq.mkString(" ")} $millPath -i mill.contrib.BSP/start" |
| 69 | + s"env ${sys.env.map { case (k, v) => s""""$k=$v"""" }.toSeq.mkString(" ")} $millPath -i mill.bsp/start" |
85 | 70 | ),
|
86 | 71 | Util.millProperty("MILL_VERSION").getOrElse(BuildInfo.millVersion),
|
87 | 72 | bspProtocolVersion,
|
@@ -113,7 +98,10 @@ object BSP extends ExternalModule {
|
113 | 98 | ev.env,
|
114 | 99 | false
|
115 | 100 | )
|
116 |
| - val millServer = new MillBuildServer(evaluator, bspProtocolVersion, BuildInfo.millVersion) |
| 101 | + val millServer = new MillBuildServer( |
| 102 | + evaluator, |
| 103 | + bspProtocolVersion, |
| 104 | + BuildInfo.millVersion) |
117 | 105 | val executor = Executors.newCachedThreadPool()
|
118 | 106 |
|
119 | 107 | val stdin = System.in
|
|
0 commit comments