Useful Leiningen Plugins

Kevin Greene

 5 min read

Clojure has a great development flow, but a few tools aren't included by default. By adding a few dependencies and plugins to ~/.lein/profiles.clj, you can make your development workflow smoother, quicker, and more effective.

Alembic

From beginner to expert, most Clojure developers spend their time in the REPL. The quick iteration and test time is a big sell for Clojure development in general. But, the fast iteration goes away as soon as you need to pull in a separate dependency. After you add the dependency to your project.clj, you then need to stop and start the REPL. All of this breaks your train of thought. Worse, if you don't have the appropriate tooling set up, you'll lose the history of your REPL.

Alembic fixes that.

With Alembic as a dependency in your project, you can easily reload your project.clj with

loading

You can also use Alembic to try out any libraries without adding them to your project.clj. For example, to add the cheshire library, run

loading

You can add Alembic to every REPL by merging the following into ~/.lein/profiles.clj.

loading

Lein Ancient

As you come back to older projects, it can be useful to update them to the latest library. Instead of going to [Clojars)[https://clojars.org/] for each library you use, instead consider using lein-ancient.

By using lein-ancient, you can determine the outdated libraries in your project.clj. Running lein ancient will produce output similar to

loading

From here, you can update any libraries as you see fit. As always, be careful blindly upgrading dependencies, and be sure to test extensively after changing any of them.

You can add lein-ancient to every project by merging the following into ~/.lein/profiles.clj.

loading

Eastwood

With ongoing projects, it can be easy to let code quality slip. Luckily, great linters like Eastwood exist to let you know when you stray from best practices.

With Eastwood as a plugin, you can run lein eastwood '{:linters [:all]}'. This produces a list of violations, that you can then work to correct. You can customize which linters you care about as described here.

This will produce an output like:

loading

You can add Eastwood to every project by merging the following into ~/.lein/profiles.clj.

loading