Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Notes on setting up vim for Clojure development.


Vim Plugins

  • vim-clojure-static
  • vim-fireplace
  • vim-classpath
  • vim-dispatch
  • ConqueTerm


First of all, Fireplace gives you <C-W> <C-D> - open symbol definition under cursor in a split. Haven't figured out how to make it work for Java methods and classes, though.

Custom functions I defined using ConqueTerm:

  • :Repl Launch a Lein REPL
  • :Clj Evaluate arbitrary Clojure code in the current buffer.


let s:CLOJURE_JAR = $HOME."/java/clojure-1.5.1/clojure-1.5.1.jar"

fun! CljCMD()
	execute 'w! /tmp/temp.clj'
	execute 'set syntax=clojure'
	execute 'ConqueTermSplit drip -cp '.s:CLOJURE_JAR.' clojure.main /tmp/temp.clj'
command! Clj call CljCMD()

fun! LeinCMD()
    execute 'ConqueTermSplit lein repl'
    execute 'set syntax=clojure'
    execute 'normal! i'
command! Repl call LeinCMD()

(Adapted from:

Now, if just want to test out some Clojure code, just create a new buffer with some code and run :Clj. If you want a full REPL, use :Repl. Since you are using drip, these commands (especially :Clj) will execute rather quickly the second time you run them.

Note that to exit either, you may need to <Ctrl-D> while in insert mode or kill the spawned Java process. Closing the buffer with :bd does not automatically kill the process.

Also notice that :Clj doesn't launch a REPL. It evaluates Clojure code. So you won't see any output unless your code actually has (println) or similar output.

What About Pipe?

I also tried to get Clojure evaluation working with vim-pipe, but couldn't get it to work:

autocmd FileType	clj		let b:vimpipe_command="drip -cp ".s:CLOJURE_JAR." clojure.main /tmp/temp.clj"
autocmd FileType	clj		let b:vimpipe_filetype="clojure"

That's because Pipe expects to read the contents of the buffer as if from stdin, as do python and ruby. But clojure.main takes either command line, script or launches a repl - so I went the ConqueTerm route.

Asynchronous Build with vim-dispatch

Dispatch allows you to launch a long-running process, such as a Leiningen build, in the background and capture the output. View the trailer.

If you launch gvim from tmux, :Make (note uppercase M) will now run lein <build target> on your tmux command line and redirect the result to Copen. It's like magic.


gvim project.clj
(In gvim)
:Make test

Other Vim Plugins

Other plugins that I installed but haven't internalized yet.

  • surround
  • vim-paredit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment