On Sun 1 Dec 2013 at 02:31:54PM -0800, Patrick Kristiansen wrote:

> Great work!

Thank you for the compliment :). Slamhound is a great tool, so I hope I
can convince more people to try it out.

> Regarding the screencast: I would be very interested to hear about
> your Clojure development setup with Vim, especially the plugins and
> configuration you are using.
>
> I see you are using some sort of split view with Vim on top and a REPL
> at the bottom. Is that GNU screen split in two or something?

The split view is a tmux feature. I typically run a headless nREPL in
one pane, then use the zoom feature to focus on the pane running Vim.

I was once a GNU screen user, but tmux is superior in most aspects, and
also sports some of the prettiest C I've ever seen.


As for Vim, version 7.3.803+ now ships with Clojure runtime files¹,
which I use together with fireplace.vim².

Many people don't know that fireplace exposes a generic eval function³
that makes writing Vim<->nREPL plugins extremely easy. For instance,
vim-slamhound is essentially just this bit of VimScript:

```
function! slamhound#reconstruct(file, textwidth)
    let file = escape(a:file, '"')
    let tw = a:textwidth < 1 ? 80 : a:textwidth
    call fireplace#eval(
        \   "(require 'slam.hound 'clojure.pprint)"
        \ . '(let [file (clojure.java.io/file "' . file . '")]'
        \ . '  (binding [clojure.pprint/*print-right-margin* ' . tw . ']'
        \ . '    (slam.hound/swap-in-reconstructed-ns-form file)))'
        \ )
    edit
endfunction

command -bar Slamhound call slamhound#reconstruct(expand('%'), &textwidth)
```

As Vim users we have to settle for building strings rather than
composing S-expressions, but this works quite well despite.


Finally, I use vim-sexp⁴ for manipulating code. I wrote this
plugin earlier in the year because I wanted to work with Clojure's
S-expressions as first-class text-objects.

The builtin bracket and string text objects are often lacking in subtle
ways, so I spent a bit of time making text objects for all three types
of compound forms, patterns and strings, comments, and a generic element
type. Combining these with Vim's operators makes hacking on Clojure a
very pleasant experience.

Vim-sexp also provides commands for wrapping, splicing, raising,
capturing, emitting, and moving S-expressions, as well as paredit-like
bracket and quote insertion (i.e. balanced insert, auto-insertion of
leading and trailing spaces).

Unlike paredit.el, however, vim-sexp does *not* try very hard at all to
keep brackets and quotes balanced, since that is not very Vim-like. IMHO
manipulating S-expressions in Vim should generally be done precisely
with operator + text-object, not sloppily with the backspace key.

I had hoped to release a screencast on vim-sexp months ago, but I never
did finish it. When I do complete it, I plan on announcing it to the
VimClojure mailing list⁵, which is recommend for discussions specific to
Vim and Clojure.


I hope you find this information useful. Exactly one year ago I became
very unsatisfied with Vim for working with Clojure, and toyed with Emacs
for a bit (evil-mode). It was nice, but I decided to stay with Vim and
create the tools that I felt I was missing. Today, I am a very happy
hacker!

    Cheers,
    guns


¹ Otherwise available at https://github.com/guns/vim-clojure-static
  courtesy of Meikel Brandmeyer, the primary author of these files.

² https://github.com/tpope/vim-fireplace

³ 
https://github.com/guns/vim-fireplace/blob/master/plugin/fireplace.vim#L525-L527https://github.com/guns/vim-sexphttps://groups.google.com/forum/#!forum/vimclojure

Attachment: pgpa87x6to9IW.pgp
Description: PGP signature

Reply via email to