Clojure and VS Code beginner setup

ClojureHub
2 min readMar 11, 2022

Thanks to JasonP for agreeing to share this tutorial. See more at clojurehub!

Hey here’s a super quick tutorial on getting VS code set up to use with Clojure & the REPL.

First, download VS Code and Leiningen. Then make a new app with leiningen and open it in VS Code.

lein new app vscode-app
cd vscode-app
code .

You might get zsh: command not found: code. If that happens open VS Code, press Shift+Command+P (on Mac), then click on “Shell Command: Install ‘code’ command in PATH”. Then you the previous command should work.

Then install a couple extensions that are helpful: Calva & Rainbow Brackets. To install extensions, you press Shift+Command+X and search for the extensions you want to add. Calva has an integrated REPL for Clojure & ClojureScript, and Rainbow Brackets helps keep track of the parentheses.

To run the REPL go to the core.clj file. In the Terminal, do lein run. Then you do Shift+Command+P again, and this time click “Calva: Start or Connect to a Clojure REPL” and select one of the options. I will do “Start your project with a REPL and connect”. For project type, I selected Leiningen. Then you can select an uberjar, but you don’t have to.

Now you should see the REPL on the right hand side of the screen, and the core.clj file on the left. If you want to evaluate code in the core.clj file, just press Option+Enter to evaluate it in-line just like in a REPL. If the expression you want to evaluate uses a function, make sure to evaluate the function definition first (also with Option+Enter).

Hope this helps.

Sources:

https://www.youtube.com/watch?v=6uUynWkMDGM&ab_channel=onthecodeagain

See the full post and similar tutorials here.

--

--

ClojureHub

Follow us for beginner Clojure web app tutorials & content. See more at clojurehub.com!