-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add spearate information about scripts
We added some info in the previous release notes, but it's better to keep it in stable documentation. I think we can start moving some feature docs to features tab to be easier to discover.
- Loading branch information
Showing
17 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
id: scripts | ||
title: Scripts support | ||
--- | ||
|
||
### Working with a script | ||
|
||
Whenever, Metals opens a script file with `*.sc` extension, but only when it's | ||
not `*.worksheet.sc` or a build server is not already started for it, users will | ||
be prompted to choose whether they want to use [Ammonite](http://ammonite.io/) | ||
or [Scala CLI](https://scala-cli.virtuslab.org/) to power the script. | ||
|
||
 | ||
|
||
Scripts are usually used for smaller programs and the main difference is that | ||
statements can be put on top level without a need for additional objects or | ||
methods. | ||
|
||
Once a user has chosen a specific scripting tool, Metals will also suggest to | ||
import all newly opened scripts automatically or to always to do that manually. | ||
|
||
Both tools will start a build server in the background that will be able to | ||
compile your code and provide Metals with all the necessary information. | ||
|
||
ScalaCLI scripts can also be used standalone when Scala CLI generated `.bsp` | ||
directory after running `scala-cli compile` or `scala-cli setup-ide` on that | ||
script. | ||
|
||
### Advanced information | ||
|
||
Additionally, advanced users can start the underlying build server manually with | ||
`Metals: Start Scala CLI BSP server` (`scala-cli-start`) or | ||
`Metals: Start Ammonite BSP server` (`ammonite-start`). They will also be able | ||
to stop it with `Metals: Stop Scala CLI BSP server`(`scala-cli-stop`) or | ||
`Metals: Stop Ammonite BSP server`(ammonite-stop). These commands can be used | ||
for more fine grained control when to turn on or of scripting support. This is | ||
especially useful since the additional build server running underneath can take | ||
up some additional resources. | ||
|
||
If the script is in a dedicated folder, by default we will treat all the scripts | ||
and scala files in that directory as ones that can be used together. So you | ||
would be able to import method and classes from those files. However, if the | ||
script is contained within a directory that also contains other sources, that | ||
script will be treated as a standalone one in order to avoid flaky compilation | ||
errors coming from normal files in the workspace. | ||
|
||
Current limitations can be found: | ||
|
||
- [here for Ammonite](https://github.com/scalameta/metals/issues?q=is%3Aopen+is%3Aissue+label%3A%22ammonite+support%22) | ||
- [here for ScalaCLI](https://github.com/scalameta/metals/issues?q=is%3Aopen+is%3Aissue+label%3Ascala-cli) | ||
|
||
For troubleshooting that a look at the [FAQ](/docs/troubleshooting/faq#ammonite-scripts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters