Evaluate Clojure From Neovim

Here's how to evaluate a buffer in neovim in a clojure repl.

Install

Conjure supports interactive evaluation of several languages from within nvim, including Clojure.

Install it with packer:

return require('packer').startup(function(use)
  -- ...
  use {
    'Olical/conjure', -- repl
    ft = 'clojure'
  }
  -- ...
end)

Evaluating

Evaluating is the main event. You get to run the code in your source file or scratch buffer inside an attached REPL.

  • <leader>eb - entire buffer

  • <leader>ee - inner form (from position of cursor, to leaf expression)

  • <leader>er - outer form (from position of cursor, to top parent expression)

  • <leader>e! - replace expression with evaluated value

  • <leader>em[mark] - at mark (previous marked, eg ma, then <leader>ema)

  • <leader>E - visual selection (previously selected)

  • <leader>E[motion] - visual selection (simultaneously specify selection)

  • <leader>ew - inspect only (previously evaluated)

Eval Buffer

The eval buffer is where the output is shown. You may also get some in-file overlays for code output, but sometimes, you'll want to see it in a persistent, larger buffer.

To position the buffer:

  • <leader>ls - horizontal split

  • <leader>lv - vertical split

  • <leader>lq - close eval buffer

  • <leader>lr - reset/clear contents

To access the latest evaluation return value:

  • "cp - paste eval result from register c

Learn More

  • :ConjureSchool - interactive teacher for these basics and a few others

  • :h conjure - general help, not clojure-specific

  • :h conjure-client-clojure-nrepl - see these and more keymappings