Configure Sublime Text build system for Scala?

2020-07-11 10:30发布

I'm trying to configure a build system for Scala with SublimeText, but I am having some difficulty. I have tried both of the following:

{
    "shell_cmd": "scala",
    "working_dir": "${project_path:${folder}}",
    "selector": "source.scala"
}

{
    "cmd": ["/path/to/bin/scala", "$file_name"],
    "working_dir": "${project_path:${folder}}",
    "selector": "source.scala",
    "shell": true
}

Both of these attempts produce the same failed output - it seems to start up the interactive Scala shell rather than running my script. Any advice?

4条回答
你好瞎i
2楼-- · 2020-07-11 10:33

This works for me:

{
    "cmd": ["scala", "$file"],
    "working_dir": "${project_path:${folder}}",
    "selector": "source.scala",
    "shell": true
}

given you set the system PATH thing:

Variable: %PATH%
Value: C:\Program Files (x86)\scala\bin
查看更多
戒情不戒烟
3楼-- · 2020-07-11 10:50

The answer that worked turned out to be very close to the second answer - apparently I'm not supposed to open up a new shell. If someone can clarify when to set "shell": true in the comments, that would be really helpful.

{
    "cmd": ["/path/to/bin/scala", "$file_name"],
    "working_dir": "${project_path:${folder}}",
    "selector": "source.scala"
}
查看更多
萌系小妹纸
4楼-- · 2020-07-11 10:56

In Packages/Scala/Scala.sublime-build, add this:

{
    "cmd": ["[PATH TO SCALA]", "$file"],
    "working_dir": "${project_path:${folder}}",
    "selector": "source.scala"
}

Replace the [PATH TO SCALA] with the path of where scala interpreter is located in your system. Do a "which scala" to find out.

查看更多
Anthone
5楼-- · 2020-07-11 10:56
{
    "cmd": ["C:/Program Files (x86)/scala/bin/scala.bat", "$file_name"],
    "working_dir": "${project_path:${folder}}",
    "selector": "source.scala"
}

This worked for me. replace C:/ with your own path.

查看更多
登录 后发表回答