These notes are intended to be used alongside this screencast, and describe some aspects of setting up and using a clojure editing environment in vim, if for some reason you don’t want to use emacs. It is very unlikely that I would ever switch to emacs, but if there is a killer feature of emacs/clojure not found here that you cannot live without, I’d be interested in knowing about it, so that I can cry myself to sleep/try to figure out if anyone in the clojure/vim community (not just for the VimClojure plugin any more) has replicated the functionality.
Follow the vim-fireplace installation instructions.
Install Rainbow-Parentheses-Improved-and2 and add the following two lines to your vim configs:
let g:rainbow_active = 1
let g:rainbow_operators = 1
- Make sure your Clojure project follows leiningen conventions, possibly by generating your project with leiningen:
lein new todos
Using this setup
In a terminal window, start up a lein repl:
In a second terminal window, open up your project in vim.
There’s lots of ways to open the file you want to edit in vim. I like using ctrlp, which has nothing to do with clojure.
These are the features from fireplace I use a lot (borrowing heavily from tpope’s docs here):
cppto evaluate the expression under the cursor
Kto look up the docs for the symbol under the cursor
[dto look up the source code for the symbol under the cursor
gfto “go to the file” corresponding to the namespace under the cursor
Require!to require the current namespace with
:reload-all, which also reloads dependencies
:help fireplacefor the rest
There’s lots of other info out there regarding using vim to write clojure, including vim docs on clojure’s site itself.