My Clojure Setup June 6, 2013
So... I've got my Clojure setup down
I've got my Clojure setup pretty much nailed.
I am using an old ThinkPad X300 running Linux Mint. Why? Well, I'm waiting for the new Haswell processors from Intel, I donated my MacBook Air to charity (I still have a MacBook Pro), I need something light for carrying around, 13" machines are much easier to code on airplanes, and I had the X300 laying around.
The X300 has a 4GB RAM limit and a slow processor (my desktop Linux box is 3 times faster.) So, I needed a dev environment that's CPU friendly and RAM friendly. While I really like IntelliJ, it's a CPU and RAM hog. IntelliJ is better for statically typed languages... but with Clojure, function completion, etc. are less valuable. So, my editor choice is Sublime Text.
My Setup
I downloaded and purchased Sublime.
I followed the instructions for installing SublimeREPL.
Then I installed a helpful indentation package.
Finally, I updated my key bindings to make them more Emacs-like:
[
{ "keys": ["ctrl+shift+-"], "command": "undo" },
{ "keys": ["ctrl+d"], "command": "right_delete" },
{ "keys": ["ctrl+a"], "command": "move_to", "args": {"to": "bol", "extend": false} },
{ "keys": ["ctrl+e"], "command": "move_to", "args": {"to": "eol", "extend": false} }
]
And my user preferences have auto-save enabled:
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"ignored_packages":
[
"Vintage"
],
"save_on_focus_lost": true
}
REPLing
My workflow is to open the Clojure REPL in Sublime. I write some code in a .clj
file,
do a ctrl-TAB
to switch to the REPL and do an up-arrow to something like:
(do (use 'plugh.core :reload-all) (thingy))
That reloads the current package and all its dependencies (which takes almost no time, even on my slow machine) then invokes a function. I just keep editing, executing, and building my code.
When I want to test, I change my namespace to a test namespace:
(ns plugh.file-test)
(use 'clojure.test)
And then I can repeatedly run tests:
(do (use 'plugh.file-test :reload-all) (run-tests))
Why Sublime vs. Emacs
I'm an Emacs lover... but Sublime has a simple feature that is awesome: ctrl-p
.
Basically, you can type ctrl-p
and then get a smart list of files in the project
and search by file name (and likely other thing). This makes project navigation
so much easier. Sublime has a nice package mechanism (yeah, Emacs 24 does, too.)
All in all, Sublime seems to work more like I do without much modification vs.
Emacs which can do everything if I spend weeks getting the packages, etc. just right.