Skip to content

Latest commit

 

History

History
99 lines (68 loc) · 1.99 KB

File metadata and controls

99 lines (68 loc) · 1.99 KB

Scala

Instructions on how I like to setup my local environment for Scala.

curl -fL https://github.com/VirtusLab/coursier-m1/releases/latest/download/cs-aarch64-apple-darwin.gz | gzip -d > cs
chmod +x cs
./cs setup --yes --jvm 17 --apps cs,sbt,bloop,scala-cli
rm cs

Setup autocompletion

https://get-coursier.io/docs/cli-installation#zsh-completions

How to switch version of Java

cs java --jvm 17 --setup
cs java --jvm 8 --setup
  1. add bloop tab completion for zsh
# https://github.com/scalacenter/bloop/releases
mkdir -p "$HOME/.bloop"
curl -L https://github.com/scalacenter/bloop/releases/download/v1.5.15/zsh-completions -o "$HOME/.bloop/zsh-completions"
ln -s "$HOME/.bloop/zsh-completions" $HOME/.zsh/completions/_bloop

scalafmt-native

Use scalafmt-native for integration with sublime-fmt

Using a scalafmt-native-launcher.

ln -s "${PWD}/scalafmt-native-launcher.sh" /usr/local/bin/scalafmt-native
mkdir -p "$HOME/.scalafmt-native"

bloop-which-project

Uses bloop to determine which project your Scala file belongs in

ln -s "${PWD}/bloop-which-project.sh" /usr/local/bin/bloop-which-project

This is used in conjuction with the bloop.sublime-build


Sublime FMT settings

{
  "rules": [
    {
      "selector": "source.scala",
      "cmd": [
        "scalafmt-native",
        "--stdin",
        "--assume-filename",
        "$file_name",
        "--stdout",
        "--non-interactive"
       ],
    }
  ],
  "cwd_mode": "project_root",
  "format_on_save": true
}