5

I'm running lein repl in a project, and it successfully starts up and creates the file target/repl-port.

Using VIM version 7.4.86 I can use a command like:

:Connect nrepl://localhost:57644

Vim then successfully connects to the repl, and all is good.

However, my understanding is that vim-fireplace is able to make this connection all by itself using the target/repl-port file. That is not happening. I did see a comment about lein 2.3 changing to use target/repl/repl-port (I use lein 2.0.0 for this project - a requirement that is out of my control) so I tried to creating a symlink at this location, but that isn't picked up either.

I'm using the version of vim-fireplace from: github.com/tpope/vim-fireplace

at the latest commit, which is currently:

f1b8096b3fe00cd9594c8a2bf0819efc154e9843
(Date:   Wed Oct 23 21:25:53 2013 -0700)

I'm hoping to automate this connection. I'm not big on VIMscript, so I was hoping that there might be some way to track down the issue without having to delve into the sources.

PaulaG
  • 336
  • 1
  • 8
  • 1
    stupid but necessary question: is VIM's working directory inside of the appropriate lein project directory? – jgriego Nov 13 '13 at 00:50
  • I should have said, sorry. Yes, it is. I'm in the directory where project.clj is. This is also the working directory of the shell where I run "lein repl". – PaulaG Nov 13 '13 at 02:53
  • So, you tried fireplace's issue tracker but it didn't help so you come here, right? – romainl Nov 13 '13 at 07:20
  • What sort of error do you get? – ponzao Nov 13 '13 at 20:42
  • No error, just no connection. If I try a symbol lookup then it says: "Error running Clojure: Error: Could not find or load main class clojure.main". But I `cat target/repl-port` and use that number to say: ":Connect nrepl://localhost:56013", then try a symbol lookup again, and it works just fine. Both "lein repl" and vim are being run in the project directory. – PaulaG Dec 04 '13 at 21:38
  • I should say... the project has source paths more like Maven's than the standard Leiningen layout. ie. src/main/clojure/... But Leiningen is fine being configured this way, and everything works, except for the autoconnect for fireplace. – PaulaG Dec 04 '13 at 21:43

3 Answers3

1

struggled a little bit with that too.

  1. Start lein repl in your project directory
  2. Start vim any-clojure-file.clj also in your project directory

Then it should connect automatically.

Fireplace only connects automatically, when you open a clojure file.

best regards

adrian

jik777
  • 51
  • 6
  • 1
    This is what I was doing already. The question is because it doesn't connect, despite following these steps. – PaulaG Dec 04 '13 at 21:33
1

I think the best way to handle this "nowadays" is with vim-leiningen. :Console will connect to a REPL if there already is one running and will start one if there isn't.

0

I too was annoyed by this and also didn't want to learn to write vim script just for this. You can work around it with your shell:

$ alias rvim="gvim $1 +\":FireplaceConnect nrepl://localhost:`cat .nrepl-port`\""
$ rvim src/something.clj
Blake Miller
  • 805
  • 11
  • 16