You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/guides/ide.md
+49-22Lines changed: 49 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,9 @@ sidebar_position: 10
4
4
---
5
5
6
6
Scala CLI currently integrates a build server using the [BSP protocol](https://build-server-protocol.github.io/).
7
-
At this moment Scala CLI is not automatically detected by IDEs, 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`).
7
+
At this moment Scala CLI is not automatically detected by IDEs, so we need to
8
+
use [Build Server Discovery](https://build-server-protocol.github.io/docs/server-discovery.html) from BSP protocol to
9
+
generate a connection details file (`.bsp/scala-cli.json`).
8
10
9
11
:::note
10
12
If none of these commands were run:
@@ -14,45 +16,52 @@ If none of these commands were run:
14
16
-`test`
15
17
-`setup-ide`
16
18
17
-
or a previously-generated connection detail file was deleted, your IDE will *not* use Scala CLI to configure your workspace.
19
+
or a previously-generated connection detail file was deleted, your IDE will *not* use Scala CLI to configure your
20
+
workspace. (Although there are ongoing efforts to improve that situation.)
18
21
19
22
In this case, just run one of the commands above to recreate the connection details file.
20
23
:::
21
24
22
25
Since Scala CLI has a command-line-first approach, this is reflected in its IDE integration.
23
-
By default, Scala CLI stores options passed to the last `compile`, `run`, or `test` command, and uses those options to configure the IDE.
26
+
By default, Scala CLI stores options passed to the last `compile`, `run`, or `test` command, and uses those options to
27
+
configure the IDE.
24
28
25
-
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.
29
+
For more control we also expose the [`setup-ide` command](../commands/setup-ide.md), which lets you fine-tune the
30
+
options that are passed to the IDE.
26
31
27
32
But note that once `setup-ide` is used, Scala CLI does not update the configuration based on latest command.
28
-
To enable automatic updates again, remove the `.bsp` directory and run `compile`, `run`, or `test` to recreate the connection details file.
29
-
30
-
<!-- TODO: Does this belong here? Is it related to IDEs? -->
31
-
For now non-local sources are supported. What are non-local sources? Gists, URLs or piped sources.
33
+
To enable automatic updates again, remove the `.bsp` directory and run `compile`, `run`, or `test` to recreate the
34
+
connection details file.
32
35
36
+
## Specific IDEs supporting Scala CLI
33
37
34
38
Scala CLI has been tested with two main Scala IDEs:
35
-
-[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
36
-
-[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
37
39
38
-
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!)
40
+
-[Metals](https://scalameta.org/metals/), which is an LSP server for Scala, and is used
41
+
with [Visual Studio Code](https://code.visualstudio.com/), [Vim](https://www.vim.org/) and many other editors
42
+
-[IntelliJ IDEA](https://www.jetbrains.com/idea/), with
43
+
the [Scala Plugin](https://confluence.jetbrains.com/display/SCA/Scala+Plugin+for+IntelliJ+IDEA?_ga=2.54176744.1963952405.1634470110-410935139.1631638301)
44
+
installed
45
+
46
+
In an ideal world we would replace the rest of this guide with something along the lines of, “Scala CLI works within
47
+
IDEs above as you would expect.” However, mainly due to how fresh Scala CLI is, and also due to our radical approach to
48
+
the project structure, using a Scala CLI project with your favourite IDE may not be as amazing as we would like. (That
49
+
being said, proper IDE integration is our top priority at this moment!)
39
50
40
-
## Metals
51
+
### VS Code with Metals
41
52
42
-
Once Metals picks up the project structure that’s created by Scala CLI, basic features like navigation, diagnostics, and code completion should work.
43
-
Reloading the workspace on project structure changes is currently experimental and should work for most scenarios, we are working on improving its stability.
44
-
For some cases it may still be necessary to restart the build server manually.
45
-
(Closing & reopening the project should also be sufficient.)
53
+
Check the cookbook on [how to set up a Scala CLI project in VSCode with Metals](../cookbooks/vscode.md).
46
54
47
-
## IntelliJ
55
+
###IntelliJ
48
56
49
-
Here are a few notes related to IntelliJ support:
50
-
- 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.
51
-
-Similarly to Metals, reloading the workspace on project structure changes is currently experimental and should work for most scenarios.
52
-
We are working on improving its stability. For some cases it may still be necessary to restart the build server manually.
53
-
(Closing & reopening the project should also be sufficient.)
57
+
Cookbooks on how to work with IntelliJ:
58
+
59
+
-[set up a simple Scala CLI project in IDEA IntelliJ](../cookbooks/intellij.md)
60
+
-[set up a Scala CLI project in IntelliJ alongside an existing SBT project](../cookbooks/intellij-sbt-with-bsp.md)
61
+
-[set up multiple Scala CLI projects in IDEA IntelliJ as separate modules](../cookbooks/intellij-multi-bsp.md)
54
62
55
63
## Directories vs single files when working with an IDE
64
+
56
65
When working with Scala CLI in an IDE, it is generally suggested to use directories rather than single files.
57
66
58
67
```shell
@@ -66,9 +75,11 @@ everything within a given project root directory is at least implicitly treated
66
75
a part of the project (and probably shown as part of your project structure).
67
76
68
77
This means that when you pass just a single source file to Scala CLI like this:
78
+
69
79
```shell
70
80
scala-cli setup-ide some-directory/A.scala
71
81
```
82
+
72
83
If you open its surrounding directory as a project, any other files present in that directory will be visible
73
84
in your IDE project's structure, but they will not be included in your builds.
74
85
@@ -77,16 +88,32 @@ alongside the previously configured `some-directory/A.scala`, it is probably not
77
88
to create the file within the same directory in your IDE.
78
89
79
90
What you need to do instead is add it to your build with Scala CLI from the command line:
0 commit comments