Working with Babashka

If you're using Babashka for your scripting needs, Cursive supports this since Cursive 1.11. Here's how to get it set up.

The first step is to ensure you configure Deps, if you haven't already. This is used to download the dependencies Babashka uses. You will also need Babashka installed according to the instructions - Cursive requires at least Babashka 0.5.1.

If you open a project containing Babashka scripts, you'll frequently see warnings that Cursive can't resolve the symbols. This is because Babashka contains a lot of built-in dependencies which Cursive doesn't know about.

You add Babashka support to a module using a facet, which is a standard IntelliJ structure often used for things like frameworks in the Java world. Ctrl+Alt+Shift+S (File→Project Structure...), select "Modules" and then select the the module you'd like to add support for. Click + and select Babashka.

Cursive should be able to default the path to your bb install correctly, but if not, enter the path here.

Assuming everything looks good, press OK and you should see a Babashka library in your project view under External Dependencies.

However, our file still has warnings. This is because Babashka scripts look like Clojure files, and Cursive doesn't know which should use the new library to resolve symbols. Once you have the facet configured you can right-click on these files and mark them as Babashka scripts.

This will cause their icon to change, and the symbol resolution in those files will now use the Babashka library instead of the module dependencies.

There's also a new Babashka Local REPL run configuration type which will allow you to start a Babashka REPL in the same way you start other local REPLs.

The Remote REPL runtime type now also understands Babashka over nREPL, so you can start a Babashka nREPL REPL on the command line and connect to it using that as well.

Macro Support Working with Polylith