123_456
, trailing commas etc., the syntax changed a lot in the last years.
val registry = new Registry()
val grammar = registry.loadGrammarFromPathSync("Scala.tmLanguage.json",
TextMateTest.getClass.getResourceAsStream("/Scala.tmLanguage.json"))
val source = "object Foo { def main(args: Array[String]): Unit = println(\"Hello\") }"
val lineTokens = grammar.tokenizeLine(source)
val tokens = lineTokens.getTokens
tokens.foreach { tk =>
val sub = source.substring(tk.getStartIndex, tk.getEndIndex)
println(s"[${tk.getStartIndex} to ${tk.getEndIndex}] source '$sub' has scopes ${tk.getScopes}")
}
[0 to 6] source 'object' has scopes [source.scala, keyword.declaration.scala]
[6 to 7] source ' ' has scopes [source.scala]
[7 to 10] source 'Foo' has scopes [source.scala, entity.name.class.declaration]
[10 to 11] source ' ' has scopes [source.scala]
[11 to 12] source '{' has scopes [source.scala, punctuation.section.block.begin.scala]
[12 to 13] source ' ' has scopes [source.scala]
[13 to 16] source 'def' has scopes [source.scala, keyword.declaration.scala]
[16 to 17] source ' ' has scopes [source.scala]
[17 to 21] source 'main' has scopes [source.scala, entity.name.function.declaration]
[21 to 22] source '(' has scopes [source.scala, meta.bracket.scala]
[22 to 26] source 'args' has scopes [source.scala, variable.parameter.scala]
[26 to 27] source ':' has scopes [source.scala, meta.colon.scala]
[27 to 28] source ' ' has scopes [source.scala]
[28 to 33] source 'Array' has scopes [source.scala, entity.name.class]
[33 to 34] source '[' has scopes [source.scala, meta.bracket.scala]
[34 to 40] source 'String' has scopes [source.scala, entity.name.class]
[40 to 41] source ']' has scopes [source.scala, meta.bracket.scala]
[41 to 42] source ')' has scopes [source.scala, meta.bracket.scala]
[42 to 43] source ':' has scopes [source.scala, keyword.operator.scala]
[43 to 44] source ' ' has scopes [source.scala]
[44 to 48] source 'Unit' has scopes [source.scala, entity.name.class]
[48 to 49] source ' ' has scopes [source.scala]
[49 to 50] source '=' has scopes [source.scala, keyword.operator.comparison.scala]
[50 to 58] source ' println' has scopes [source.scala]
[58 to 59] source '(' has scopes [source.scala, meta.bracket.scala]
[59 to 60] source '"' has scopes [source.scala, string.quoted.double.scala, punctuation.definition.string.begin.scala]
[60 to 65] source 'Hello' has scopes [source.scala, string.quoted.double.scala]
[65 to 66] source '"' has scopes [source.scala, string.quoted.double.scala, punctuation.definition.string.end.scala]
[66 to 67] source ')' has scopes [source.scala, meta.bracket.scala]
[67 to 68] source ' ' has scopes [source.scala]
[68 to 69] source '}' has scopes [source.scala, punctuation.section.block.end.scala]
sbt --client
works but still has bugs with autocompletion and disconnects on Mac so
sbt --client
first in the workspace, then open the project in Metals if you've chose sbt as a BSP server
.bsp/<server>.json
file exists, that's an indication that it should be started. So in this situation when you've chosen to use sbt as a build server at some point in time and open the project, metals remembers that, follows BSP discovery rules and starts the server since it needs that in order to function
There's this setting already:
Sbt Script
Optional absolute path to an sbt executable to use for running sbt bloopInstall.
By default, Metals uses java -jar sbt-launch.jar with an embedded launcher while respecting .jvmopts and .sbtopts.
Update this setting if your sbt script requires more customizations like using environment variables.
But this is not honored.