This repository has been archived by the owner on Jul 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
ServerType.scala
81 lines (65 loc) · 2.33 KB
/
ServerType.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package laughedelic.atom.ide.scala
import io.scalajs.nodejs.path.Path
import scala.scalajs.js, js.annotation._, js.Dynamic.global
import laughedelic.atom.Atom
sealed trait ServerType {
val name: String
val description: String
val defaultVersion: String
def javaArgs(projectPath: String): Seq[String]
def coursierArgs(javaHome: String, version: String): Seq[String]
def watchFilter(filePath: String): Boolean
}
case object ServerType {
case object Metals extends ServerType {
val name: String = "metals"
val description: String = "Metals (Scalameta language server)"
val defaultVersion: String = "6f55b052"
def javaArgs(projectPath: String): Seq[String] = Seq()
def coursierArgs(javaHome: String, version: String = defaultVersion): Seq[String] = Seq(
"--repository", "bintray:dhpcs/maven",
"--repository", "bintray:scalameta/maven",
s"org.scalameta:metaserver_2.12:${version}",
"--main", "scala.meta.languageserver.Main"
)
def watchFilter(filePath: String): Boolean = {
filePath.endsWith(".semanticdb") ||
filePath.endsWith(".compilerconfig")
}
}
case object Ensime extends ServerType {
val name: String = "ensime"
val description: String = "ENSIME (experimental)"
val defaultVersion: String = "3.0.0-SNAPSHOT"
def javaArgs(projectPath: String): Seq[String] = Seq(
"-Xmx4G", // heap size
// FIXME: how to setup classpath properly without parsing .ensime config?
// "-classpath", classpath,
s"-Dlsp.workspace=${projectPath}",
// TODO: add log level to the plugin settings
s"-Dlsp.logLevel=DEBUG",
)
def coursierArgs(javaHome: String, version: String = defaultVersion): Seq[String] = {
val toolsJar = Path.join(javaHome, "lib", "tools.jar")
Seq(
"--extra-jars", toolsJar,
"--repository", "bintray:dhpcs/maven",
"--repository", "sonatype:snapshots",
s"org.ensime:server_2.12:${version}",
"--main", "org.ensime.server.Server",
"--", "--lsp"
)
}
def watchFilter(filePath: String): Boolean = {
// TODO: should be more precise:
filePath.contains(".ensime")
}
}
def fromConfig: ServerType = {
Config.serverType.get match {
case Metals.name => Metals
case Ensime.name => Ensime
}
}
val values = Seq(Metals, Ensime)
}