This loose guide is aimed to assist (mainly my coworkers) in setting up a Clojure development environment on Windows, preferably using Clojure Development Environment (Windows) (within Clojure Development Environment (Windows)) serving as a pretty full-fledged Clojure IDE!

Scoop

Scoop

Scoop is an easy to use command-line installer for Windows. It significantly streamlines the experience of installing and managing software (especially for development purposes)! And the best thing? It lives in user-space as much as possible!

Note

It is always recommended to reference up-to-date documentation, particularly Scoop’s own website when installing!

Install

Simply run the following command(s) from a PowerShell terminal:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression

This will automagically install scoop!

Install a package

Generally a simple scoop install <package> will suffice!

It could however be that the package is not contained within the default bucket. Buckets are collections of packages, organized by categories, or even supplied by external repositories. One of the most utilized buckets would be extras, for example. To add a bucket, simply do scoop bucket add <bucket>.

Finally, to search for a package, you can do scoop search <package> and it will even show you what bucket it belongs to!

Link to original

Requirements

Now that we have setup Scoop, we need to install a couple of dependencies for both Clojure Development Environment (Windows), as well as Clojure Development Environment (Windows) later on in the guide.

Info

The following part was largely adopted from the scoop-clojure Project’s GitHub page.

Git

Git is required by Calva and also often times the recommended VCS (Version Control System). Install it using scoop:

Transclude of Git#Scoop

Java

As Clojure runs on the JVM (Java Virtual Machine), we obviously need to install Java, specifically a JDK (Java Development Kit).

The most pain-free approach is to install it, too, using Scoop!

Hint

You can, of course, also do a more manual approach, by downloading it, installing it and making sure JAVA_HOME is correctly set. But as stated previously, scoop just Makes-It-Work™.

For that you simply have to add the java bucket and install the (TCK certified) Java runtime and compiler:

Transclude of Temurin#Scoop

Clojure

Now we can finally install the official clojure tools!

Transclude of Clojure#Scoop

Proxy

If you are sitting behind a corporate proxy, you need to set the proxy for Clojure (Maven to be exact) first!

Clojure/Maven both use the same centralized .\m2\settings.xml config file for that. Under Windows the config file should be located (or not created) in your User directory (C:\Users\<username>)

Populate the file with, or add merge with already present sections (the relevant lines have been highlighted):

~/.m2/settings.xml
<settings>
    <proxies>
        <proxy>
            <active>true</active>
            <host>proxy.domain.de</host>
            <port>8080</port>
        </proxy>
    </proxies>
</settings>

and you should be good to go.

Info

This is mainly for the clojure and deps.edn specific stuff to work.

Optional Tooling

There are some (of course, optional) tools I like to use.

I use Clojure Development Environment (Windows) for easily managing project dependencies, common aliases and for quick project creation, while I use Babashka for quick scripting that doesn’t warrant a whole project structure.

deps-new

For a new project (and as an alternative/fallback to neil), you can simply use deps-new, which setups a deps.edn project. It doesn’t have shiny bling-bling, but works.

Especially since I had some problems with Clojure Development Environment (Windows) (and therefore Clojure Development Environment (Windows), which depends on it) working correctly behind a Proxy! As it uses the default clojure tools, the proxy setup described below works correctly for deps.edn projects created by deps-new.

deps-new should be installed as a clojure tool, so execute

clojure -Ttools install-latest :lib io.github.seancorfield/deps-new :as new

Refer to the official README.md section for creating an application or a minimal scratch project.

Tip

If you’re unfamiliar with clojure, the application template is pretty convoluted. Instead I’d recommend to use the minimal scratch template while getting started.

Look inside src/scratch.clj for some hints on running your first commands.

Babashka

Transclude of Babashka#Why tho?

Circular transclusion detected: Babashka

neil

Transclude of neil#Scoop

Visual Studio Code

Our editor will be Visual Studio Code (or VS Code) and also what we will install Clojure Development Environment (Windows) in (which is actually just an extension).

It has really nice feature, like an integrated terminal pane, versatile extensions and plugins, great LSP support and so much more that makes it a great IDE.

Simply download and install it from either the Microsoft Website using their installer, or using Scoop:

Transclude of Visual-Studio-Code#Scoop

Calva

Of course, we want a nice development environment for Clojure. This is why we’ll use Calva. It’s a very nice batteries-included framework for Clojure development within VS Code.

To install it:

  1. Open VS Code
  2. Go to (in the menu bar)
    1. File
    2. Preferences
    3. Extensions
  3. Search for Calva
  4. Select Calva: Clojure & ClojureScript
  5. Click on Install

After that, simply open your project folder inside VS Code and Calva should automagically start everything, including clojure-lsp as the LSP server, their formatter and much more.

How do I use this thing?!

As for keybinds and generell development workflow, please refer to the upstream Calva documentation!

Generally, though, you should be able to use Ctrl+Alt+C for some Calva-specific commands (needs to be followed by command specific keys!), or use the general VS Code command palette/search using Ctrl+Shift+P!

You should try to use the “Jack-in” feature for Calva to start a REPL in you project directory, so you can easily evaluate any S-Expression, or in other non-LISPy words, statements enclosed in (...) (so, … everything really!) using Alt+Enter.

(Using the command palette, it’s called Calva: Start a Project REPL and Connect)

Also you might wonder why it auto inserts brackets and doesn’t let you delete it?! Well as you might’ve guessed when looking at some Clojure source code, keeping track of the right number of parentheses is hard! So that’s why many use systems to keep track for them. Utilize the right keybinds/commands for that! For example search for slurp and barf commands (Ctrl+Shift+. and Ctrl+Shift+,) in the command palette and see what happens.

But as I said: Use the documentation!

Other Editors / IDEs

There are of course alternatives to Calva. A non-exhaustive list is provided (the ones I have tried personally), though you should checkout the official Clojure Editors list for further suggestions.

Emacs

I’m in no position to call other people savage-madmans, but running Emacs on Windows, at least natively, is something I’ve long given up on. If you value your sanity, use a WSL 2 - Distro for that!

In any case, have a look at Cider. Cider is one of the most feature-complete implementations of a true LISP agnostic development experience I have encountered!

Neovim

Slightly better to run on Windows (natively) compared to Clojure Development Environment (Windows).

There’s a Cider equivalent (more or less) for Neovim called conjure (fittingly). The good thing about it is that is also supports a bunch of other languages within and outside the LISP family, including but not limited to:

Cursive

Cursive is a Clojure(Script) IDE built on JetBrains IntelliJ (a Java IDE).

It is not free, though there exists a Personal license available for purchase that could satisfy your needs:

![quote] Available to individuals purchasing the licence for their own use with their own money. May not be purchased or reimbursed by companies, but may be used at work by the named user. This licence is perpetual, with free updates for a year. (EULA)

Cursive purchase page

This means you could legally (at least as far as Cursive is concerned) use it in your job.