Fork me on GitHub


An embedded editor for Clojure

What is it?

Nightlight is an editor you run inside your Clojure projects. Instead of being a separate application like traditional editors and IDEs, it's just a library that you add to your project. It spins up a web server and provides a completely browser-based interface to edit your code.

By running inside your project, it has complete access to the running state of your program. The ambition is to create something that follows the Lisp and Smalltalk tradition, blurring the line between your tools and your code to provide unprecedented interactivity.

Join the discussion on /r/Nightcode and read the source code.

How do I get started?

For Boot users...

Add it to your build.boot:

  :source-paths #{"src"}
  :dependencies '[[org.clojure/clojure "1.8.0"]
                  [nightlight "1.6.3" :scope "test"]])

(require '[nightlight.boot :refer [nightlight]])

(deftask run []
    (nightlight :port 4000)))

For Leiningen users...

Add it to your ~/.lein/profiles.clj:

{:user {:plugins [[nightlight/lein-nightlight "1.6.3"]]}}

Then, in your project, run lein nightlight --port 4000

What can it do?

Code Completion

The right sidebar is constantly showing you code completion suggestions as you type. It works with all your third-party libraries as well. Just hit tab to select the first, or click another item in the list.


Since it's running inside your project, Nightlight provides a REPL for free. No need to fiddle with connections -- just click the REPL tab in the left sidebar.


In addition to a standard REPL, you can enable an instaREPL for any Clojure file. That will cause the code to be constantly evaluated as you type, with the results shown on the left.

What about ClojureScript?

Nightlight can optionally display a ClojureScript REPL tab that contains an embedded view of your ClojureScript app and a REPL that can access it. Additionally, it will enable the instaREPL in all your ClojureScript files.

Setting it up involves just two steps:

1. Require nightlight.repl-server in your ClojureScript app

Just add it to your main ns form like this:

(ns hello-world.core
  (:require [nightlight.repl-server]))

Note: Leiningen users will also need to add Nightlight to the dependencies vector in project.clj:

[nightlight "1.6.3"]

2. Tell Nightlight what address your ClojureScript app is running on

For Boot users, just pass the URL into the boot task:

(deftask run []
    (serve :dir "target/public" :port 3000)
    (cljs :source-map true :optimizations :none)
    (nightlight :port 4000 :url "http://localhost:3000")))

For Leiningen users, pass the URL into the command:

lein nightlight --port 4000 --url "http://localhost:3000"

That's it! This is quite possibly the simplest setup process you'll find for a ClojureScript REPL.

Can I use this to develop on a remote server?

Absolutely. Run Nightlight on your desired port, and make sure the server is exposing that port publicly. To prevent security issues, Nightlight allows you to require a username and password.

For Boot users, it's recommended that you do this in ~/.boot/profile.boot:

(set-env! :dependencies '[[nightlight "1.6.3" :scope "test"]])
(require '[nightlight.boot :refer [nightlight]])
(task-options! nightlight {:user "admin passw0rd"})

For Leiningen users, do this in the command:

lein nightlight --port 4000 --user "admin passw0rd"

How does this compare to Nightcode?

Nightcode is a Clojure IDE I've been working on for some time. It works like any traditional IDE, running in its own process. I have always struggled to provide features like code completion because they require a deep understanding of your project, including its dependencies.

More powerful editors like Cider and Cursive manage to do this with some very complex machinery that I could never duplicate. Instead, I decided to rethink the problem. Since Nightlight runs inside the same process as your project, code completion and other advanced features are trivial to implement.