Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import scala-cli scripts directory as bsp module into Intellij sbt project #260

Closed
Krever opened this issue Oct 21, 2021 · 3 comments
Closed
Assignees

Comments

@Krever
Copy link

Krever commented Oct 21, 2021

I'd like to try to accommodate following use case with scala-cli: keep some scripts alongside my main project and still be able to browse/navigate them in IntelliJ.
I wasn't able to achieve it with ammonite, so I have huge hopes for scala-cli.

I tried to accomplish it by importing a script dir as bsp module into my project. Detailed steps below:

  1. Create simple script under scripts dir
mkdir -p scripts
cat <<'EOT' > scripts/script.sc
import $ivy.`com.lihaoyi::upickle:1.4.0`
import ujson._
EOT
  1. run it with scala-cli scripts/script.sc
  2. prepare ide support with scala-cli setup-ide scripts
  3. Import the directory in Intellij with File -> New -> Module from existing sources -> select scripts dir -> select BSP import

Unfortunately, this doesn't add the upickle to the classpath and so ujson is not recognized.

I'm not familiar with BSP that much but the generated .bsp/scala-cli.json file doesn't seem to mention external dependencies in any way.

@romanowski
Copy link
Member

I'm not familiar with BSP that much but the generated .bsp/scala-cli.json file doesn't seem to mention external dependencies in any way.

That is expected. Generated .bsp file only stores general configuration, rest is handled under the hood. I was trying it a bit and it seems that there is a combination of issues here (some come from Intellij, some come from scala-cli) that I am trying to untangle.

@romanowski romanowski self-assigned this Oct 21, 2021
@Krever
Copy link
Author

Krever commented Oct 22, 2021

Thanks a lot. This comment from @alexarchambault seems relevant, but doesn't sound too optimistic :(
https://twitter.com/alxarchambault/status/1451303332627329033?s=20

*.sc files shouldn't work fine via BSP, with today's instructions. It's only for *.scala files.

They can be supported from Metals with a modified Metals server though, but it's not documented for now.

@Gedochao
Copy link
Contributor

image

This seems to be working fine now in IntelliJ, closing this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants