July 13, 2015 clojure vim

'(Clojure, Vim, nREPL, Fireplace, REDL Setup)

These are the steps I take to set up a new Arch system with a Clojure environment for vim.

  • Get lein up to date

    lein update
  • Install new version of clojure, eg, Arch: yaourt -S clojure

  • Update lein search index: lein search whatever

  • Set up fireplace, highlighting, mappings, sexp into .vimrc with Vundle:

    Plugin 'guns/vim-clojure-static.git'
    Plugin 'guns/vim-clojure-highlight.git'
    Plugin 'tpope/vim-leiningen.git'
    Plugin 'tpope/vim-dispatch.git'
    Plugin 'tpope/vim-fireplace.git'
    Plugin 'tpope/vim-sexp-mappings-for-regular-people'
    Plugin 'guns/vim-sexp'
    Plugin 'guns/vim-slamhound'
    Plugin 'dgrnbrg/redl'
  • Add to ~/.lein/profiles.clj:

    {:user {:plugins [...
                      [cider/cider-nrepl "0.10.0"] ]
            :dependencies [...
                           [spyscope "0.1.5"]
                           [redl "0.2.4"] ]
            :injections [...
                         (require 'spyscope.core)
                         (require '[redl complete core]) ]}}
  • Create new project:

    lein new foo
  • Add to each project:

    :main foo.core
    :repl-options {:init-ns foo.core})
  • Run lein deps

  • Start tmux? Maybe not; slime not working now anyway

Now you need an nrepl running somewhere. You can either:

  • Start lein repl in a terminal

  • Or, in vim, run: :Console to fire up nrepl in a new shell (or tmux window if tmux is running)

Now finally…​.

  • Fire up vim if you haven’t already (fireplace will auto-connect to running nrepl)

  • In vim, run: :Eval (require '[redl core complete]) (might not be necessary for you)

  • Start redl with :ReplHere

  • Start drip (optional)

    export LEIN_JAVA_CMD=drip  # could make lein hang on app template
  • Stop drip (later) with drip kill

TLDR for next time

% cd some-project
% lein repl  # and twiddle your thumbs
% vim src/.../foo.clj
" Play with fireplace commands, like cpp
:Eval (require '[redl core complete])
:ReplHere
" Do things in vim in the real nrepl!