Skip to content

Commit 3030f6e

Browse files
authored
Merge pull request #311 from alvinj/aa-guides-review
Finished reviewing the Guides pages
2 parents 84d27d0 + 3943fa2 commit 3030f6e

File tree

10 files changed

+223
-170
lines changed

10 files changed

+223
-170
lines changed

website/docs/guides/configuration.md

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ title: Configuration
33
sidebar_position: 9
44
---
55

6-
`scala-cli` can be configured in several ways:
6+
`scala-cli` can be configured in two ways:
77
- on the command-line
88
- directly in `.scala` and `.sc` files
99

10-
Parameters on the command-line take precedence over parameters in sources.
11-
That way, you can quickly override parameters from the command-line.
10+
Parameters on the command line take precedence over parameters in sources.
11+
That way, you can quickly override parameters from the command line.
1212

13-
Note that the configuration options and syntax in `.scala` files is likely
14-
to evolve in the future.
13+
:::warning
14+
The configuration options and syntax in `.scala` (and `.sc`) files is likely to evolve in the future.
15+
:::
1516

1617
## Command-line
1718

@@ -21,15 +22,24 @@ scala-cli --help
2122
scala-cli package --help
2223
```
2324

24-
For example, you can specify the Scala version, or add dependencies, on the command-line:
25+
As an example of command line configuration, one thing you can do with `scala-cli` command line options is to specify the Scala version:
2526
```bash
2627
scala-cli --scala 3.0.0 Test.scala
28+
```
29+
30+
Another thing you can do is to specify dependencies:
31+
```bash
2732
scala-cli --dependency org.typelevel::cats-core:2.3.0 Test.scala
2833
```
2934

30-
The reference documentation lists [all available options](../reference/cli-options.md).
35+
The reference documentation lists [all of the available options](../reference/cli-options.md).
36+
3137

32-
## Special imports
38+
## In .scala and .sc files
39+
40+
Configuration information can also be put in `.scala` and `.sc` files using special imports, and the `using` directive.
41+
42+
### Special imports
3343

3444
Dependencies can be added right from `.scala` and `.sc` files, using the same
3545
syntax as Ammonite and Metals worksheets:
@@ -42,15 +52,17 @@ import ujson._
4252

4353
Both `import $ivy` and `import $dep` are accepted, and are equivalent.
4454

45-
## Using directives
55+
### Using directives
4656

47-
Scala CLI can be configured from `.scala` files. You can specify `using` directives at the
48-
top of a `.scala` file, before any `package` or `import` statement.
57+
Scala CLI can be configured inside `.scala` files.
58+
This is achieved by specifying `using` directives inside comments at the top of a `.scala` file, before any `package` or `import` statement:
4959

5060
```scala
51-
using scala 2.13
52-
using scala-js
53-
using options -Xasync
61+
// using scala 2.13
62+
// using scala-js
63+
// using options -Xasync
64+
65+
// package and import statements follow here ...
5466
```
5567

5668
The reference documentation lists [all available using directives](../reference/directives.md#using-directives).

website/docs/guides/dependencies.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@ sidebar_position: 9
55

66
# Dependencies
77

8-
You can add dependencies on the command-line, via `--dependency`:
8+
You can add dependencies on the command line, with the `--dependency` option:
99
```bash
1010
scala-cli compile Hello.scala \
1111
--dependency org.scala-lang.modules::scala-parallel-collections:1.0.4
1212
```
1313

14-
Note that `--dependency` is only meant as a convenience. You should favour
15-
adding dependencies in the sources themselves via [using directives](./guides/configuration.md#special-imports). However, `--dependency` CLI option takes precedence over using directives, so it can be used to override version temporarily.
14+
Note that `--dependency` is only meant as a convenience.
15+
You should favor adding dependencies in the sources themselves via [using directives](./guides/configuration.md#special-imports).
16+
<!-- TODO #344
17+
However, `--dependency` CLI option takes precedence over `using` directives, so it can be used to override the `using` directive, such as when you want to work with a different dependency version. -->
1618

1719
You can also add repositories on the command-line, via `--repository`:
1820
```bash
19-
scala-cli compile Hello.scala --dependency com.pany::util:33.1.0 --repo https://artifacts.pany.com/maven
21+
scala-cli compile Hello.scala \
22+
--dependency com.pany::util:33.1.0 --repo https://artifacts.pany.com/maven
2023
```
2124

22-
Lastly, you can also add simple JAR files as dependencies, with `--jar`:
25+
Lastly, you can also add simple JAR files as dependencies with `--jar`:
2326
```bash
2427
scala-cli compile Hello.scala --jar /path/to/library.jar
2528
```

website/docs/guides/ide.md

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,55 @@ sidebar_position: 10
44
---
55

66
:::warning
7-
IDE support is under development mainly because changes needs to be done in both Metals and IntelliJ.
7+
IDE support is currently under devlopment, primarily because changes needs to be made in both Metals and IntelliJ.
88
:::
99

1010

11-
Scala CLI currently Scala integrates with IDEs using [BSP protocol](https://build-server-protocol.github.io/). At this moment Scala CLI is not automatically detected so we need to use [Build Server Discovery](https://build-server-protocol.github.io/docs/server-discovery.html) from the BSP protocol. This is the main reason we create the BSP connection details file (`.bsp/scala-cli.json`) for your editor to pick up.
11+
Scala CLI currently integrates with a build server using the [BSP protocol](https://build-server-protocol.github.io/).
12+
At this moment Scala CLI is not automatically detected, so we need to use [Build Server Discovery](https://build-server-protocol.github.io/docs/server-discovery.html) from BSP protocol to generate a connection details file (`.bsp/scala-cli.json`).
1213

1314
:::note
14-
If none of the following commands were ran: `compile`, `run`, `test`,
15-
`setup-ide` or a `.bsp/scala-cli.json` file has yet to be created (or was deleted), your editor
16-
won't pick up scala-cli as a build server. In that case, simply run one of the
17-
those commands and the file will be created.
18-
:::
15+
If none of these commands were run:
1916

20-
Since Scala CLI has a command-line-first approach that is reflected in the IDE
21-
integrations. By default, Scala CLI stores options passed to the last `compile`,
22-
`run` or `test` commands and use those options to configure your IDE.
17+
- `compile`
18+
- `run`
19+
- `test`
20+
- `setup-ide`
2321

24-
For more control we also expose a [`setup-ide` command](../commands/setup-ide.md) that allows to fine tune options passed to IDE.
22+
or a previously-generated connection detail file was deleted, your IDE will *not* use Scala CLI to configure your workspace.
2523

26-
Once `setup-ide` is used, Scala CLI does not update configuration based on the latest command.
24+
In this case, just run one of the commands above to recreate the connection details file.
25+
:::
2726

28-
To enable automatic updates again, remove the `.bsp` directory and run `compile`, `run` or `test` to recreate the connection details file (`.bsp/scala-cli.json`).
27+
Since Scala CLI has a command-line-first approach, this is reflected in its IDE integration.
28+
By default, Scala CLI stores options passed to the last `compile`, `run`, or `test` command, and uses those options to configure the IDE.
2929

30-
For now non-local sources are supported. What are non-local sources? Gists, URLs or piped sources.
30+
For more control we also expose the [`setup-ide` command](../commands/setup-ide.md), which lets you fine-tune the options that are passed to the IDE.
3131

32+
But note that once `setup-ide` is used, Scala CLI does not update the configuration based on latest command.
33+
To enable automatic updates again, remove the `.bsp` directory and run `compile`, `run`, or `test` to recreate the connection details file.
3234

33-
Scala CLI was tested with two main IDEs for Scala:
34-
- [Metals](https://scalameta.org/metals/): LSP server for Scala used with [Visual Studio Code](https://code.visualstudio.com/), [Vim](https://www.vim.org/) and many other editors
35-
- [Intelij Idea](https://www.jetbrains.com/idea/) with [Scala Plugin](https://confluence.jetbrains.com/display/SCA/Scala+Plugin+for+IntelliJ+IDEA?_ga=2.54176744.1963952405.1634470110-410935139.1631638301) installed
35+
<!-- TODO: Does this belong here? Is it related to IDEs? -->
36+
For now non-local sources are supported. What are non-local sources? Gists, URLs or piped sources.
3637

37-
In ideal world, we would replace the rest of this Guide with something along the
38-
lines of: `Scala CLI works with all IDEs above as you would expect` however
39-
mainly due to how fresh Scala CLI is and also due to our radical approach to the
40-
project structure using a Scala CLI-powered projects with your favourite IDE may
41-
not be as amazing as we would like to be.
4238

43-
Proper IDE integration is our top priority at the moment.
39+
Scala CLI has been tested with two main Scala IDEs:
40+
- [Metals](https://scalameta.org/metals/), which is an LSP server for Scala, and is used with [Visual Studio Code](https://code.visualstudio.com/), [Vim](https://www.vim.org/) and many other editors
41+
- [IntelliJ IDEA](https://www.jetbrains.com/idea/), with the [Scala Plugin](https://confluence.jetbrains.com/display/SCA/Scala+Plugin+for+IntelliJ+IDEA?_ga=2.54176744.1963952405.1634470110-410935139.1631638301) installed
42+
43+
In an ideal world we would replace the rest of this guide with something along the lines of, “Scala CLI works within IDEs above as you would expect.” However, mainly due to how fresh Scala CLI is, and also due to our radical approach to the project structure, using a Scala CLI project with your favourite IDE may not be as amazing as we would like. (That being said, proper IDE integration is our top priority at this moment!)
4444

4545
## Metals
4646

47-
Once Metals picks up proper project structure then basic features like navigation, diagnostics or code completion should work.
47+
Once Metals picks up the project structure that’s created by Scala CLI, basic features like navigation, diagnostics, and code completion should work.
4848

49-
The Current release Metals (0.10.8) is not able to pick changes in the build
50-
structure automatically and this includes adding new source files. In order
51-
for Metals to pick up new files or changes in build structure you'll need to
52-
trigger the 'Restart build server' command.
5349

54-
Main classes and tests are at this moment not recognized in Metals.
5550

56-
Generally, mainly due to problems with keeping project structure up to date
57-
Metals can assists with writing code while using Scala CLI, but it cannot be the
58-
source of truth and we recommend falling back to command line in such cases.
5951

6052
## IntelliJ
6153

62-
In terms of IntelliJ, the most significant problem is that IntelliJ requires sources to be placed within a directory. This means that top level sources are not recognized as proper sources.
63-
64-
With IntelliJ, we strongly suggested to placed your sources within a directory (like `src`).
65-
66-
IntelliJ currently does not automatically pick up changes in project structure so any change in dependencies, compiler options etc. needs manual reload.
54+
Here are a few notes related to IntelliJ support:
6755

68-
Similarly to Metals, we don't currently advise using Intellij as a source of
69-
truth and we recommend falling back to command line in such cases.
56+
- The most significant problem with IntelliJ is that it requires sources to be placed within a directory. Therefore, if you use IntelliJ, we strongly suggest that you place your sources in a directory (like `src`).
57+
- IntelliJ currently does not automatically pick up changes in the project structure, so any change in dependencies, compiler options, etc., need to be manually reloaded.
58+
- We currently don’t advise using IntelliJ as a source of truth, and we recommend falling back to command line in such cases.

0 commit comments

Comments
 (0)