如何在 Visual Studio Code 的用户界面中执行 dotty 代码

5

我正在尝试使用Visual Studio Code运行dotty代码。我按照此页面的说明,使用sbt launchIDE启动了IDE,并安装了Dotty Language ServerCode Runner扩展程序。我使用brew安装了Dotty,并且可以从CMD编译和执行dotty代码。

问题在于,我无法从Visual Studio Code运行此代码,因为Code Runner试图使用scala而不是dotty来执行它。

找不到任何有用的配置来调整此插件以使用dotty。

是否有任何方法使其在Visual Studio Code UI中运行?


你的问题需要更多关于你的环境的信息,例如你使用的操作系统是什么。 - analystic
1个回答

3

克隆仓库https://github.com/lampepfl/dotty-example-project(在页面https://dotty.epfl.ch/docs/usage/getting-started.html中提到),然后运行。

sbt launchIDE

这在https://dotty.epfl.ch/docs/usage/ide-support.html中提到。

代码应该使用scala运行(运行时相同)。如果使用scalac编译代码而不是dotty,则可能意味着build.sbt中的scalaVersion错误或者plugins.sbt中没有打开dotty sbt插件。

enter image description here

build.sbt

lazy val root = project
  .in(file("."))
  .settings(
    name := "dottydemo",
    version := "0.1",
    scalaVersion := "0.13.0-RC1"
)

plugins.sbt

addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.3.0")

另外,您可以尝试使用IntelliJ IDEA(虽然它没有官方支持)在Intellij IDE中运行Scala Dotty项目


是的。我所有的配置文件都包含正确的配置和版本,我正在使用sbt launchIDE,但是当我从UI中执行“Run Code”时,它会使用scala编译代码,而不是dotty。我也无法从你的截图中编译代码。对我来说,“sbt compile”和“sbt run”命令都很好用。也许我需要在Visual Studio Code上安装一些额外的sbt扩展。 - Bogdan Vakulenko
@BogdanVakulenko 你解决问题了吗?如果是的话,怎样解决的? - Timo Meijer
很遗憾,不行。我刚开始使用命令行工具进行编译和运行。 - Bogdan Vakulenko
@BogdanVakulenko 我现在使用任务(ctrl-shift-p -> 任务)来完成它。我为sbt runsbt ~run分别创建了任务,这对于我来说非常好用,可以运行/测试代码。 - Timo Meijer

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接