Vim: Connect to Clojure nREPL inside the VM

For Vim to talk to nREPL we will be using fantastic fireplace.vim plugin. If you have Clojure installed locally, this plugin will connect to its nREPL automatically based on .nrepl-port. But if you, like me, have Clojure inside the VM (VirtualBox or VMWare, or something else), you need to connect to its nREPL manually using :Connect function.

This function has the following syntax:

:Connect {proto}://{host}:{port} {path}

Most of the options are self-explanatory, except to say that proto (protocol) is always nrepl and path is your project’s location.

I am using Vagrant to manage my VMs and this one, as the rest, configured with private network.

Vagrant.configure("2") do |config| "private_network", ip: ""

Now we need to start nREPL inside the guest machine.

$> lein repl :start :host :port 4242

You could omit the :port option, in which case leiningen will use a random port.

One thing remains is to connect to nREPL.

:Connect nrepl://

Now you should be able to run fireplace.vim commands. Try :Doc get for example.


comments powered by Disqus