Metaphysical Developer

Idiomatic Clojure with LightTable

Posted in Clojure, Software Development by Daniel Ribeiro on November 18, 2013

LightTable, the famous innovative IDE (slash reactive work surface, as described by the author) recently got some pretty amazing additions: user defined plugins and user defined custom expressions.

Custom expressions allow users to define functions that get any block of text and replace with the result, stream information back to LightTable, or display the result inline:

image

The clojure project Kibit immediately came to mind when I saw the new addition. Kibit is a static code analyzer for Clojure that allows you to find a more idiomatic way of writing a given block of text.

So I wrote this short LightTable integration for it. With it, LightTable can replace any s-expression with its more idiomatic version. For instance, this code:

Screen Shot 2013-11-17 at 5.53.01 PM

becomes:

Screen Shot 2013-11-17 at 5.53.21 PM

To see how Kibit did, here is the before and after shots of the expression broken down in its components:

s0

After:

s1

In order to use Kibit with LightTable, you just need to:

1. add lein-kibit it to your project.clj:

Screen Shot 2013-11-17 at 5.56.49 PM

2. add the integration function to your usermap:

Screen Shot 2013-11-18 at 10.54.40 PM

The sample project can be found on GitHub.

Tagged with: ,

Comments Off on Idiomatic Clojure with LightTable