Calva (VS Code)

We’re working on adding an out-of-box project type for Gradle to Calva. That will simplify the usage described here.

Once you’re jacked-in or connected, see Calva’s documentation for usage information.

(Manual) Add dependencies to your build

If you want to control the dependencies yourself, here are the needed changes to manually configure your project for use with Calva.

Build Config

build.gradle
dependencies {
  devImplementation 'cider:cider-nrepl:0.28.5'
}

clojureRepl {
  middleware = ['cider.nrepl/cider-middleware']
}

Connect to already running REPL (Custom)

Create a custom Calva connect sequence in your user or workspace settings.json.

settings.json
{
  "calva.replConnectSequences": [
    {
      "name": "Custom Gradle",
      "projectType": "generic",
      "nReplPortFile": [
        ".nrepl-port"
      ],
      "cljsType": "none"
    }
  ]
}

Start your nREPL server.

$ ./gradlew clojureRepl

Optionally, omit the middleware from the build.gradle and include it on the commandline:

$ ./gradlew clojureRepl --middleware=cider.nrepl/cider-middleware

Then Calva: Connect to a Runnig REPL Server in the Project (CTRL+ALT+C CTRL+ALT+C). Choose the Custom Gradle project type. Calva will pick up the port automatically.

(or) Connect to already running REPL (Generic)

Start your nREPL server.

$ ./gradlew clojureRepl

Optionally, omit the middleware from the build.gradle and include it on the commandline:

$ ./gradlew clojureRepl --middleware=cider.nrepl/cider-middleware

Then Calva: Connect to a Runnig REPL Server in the Project (CTRL+ALT+C CTRL+ALT+C). Choose the Generic project type and input the REPL port from your Gradle output.