Hacker News new | past | comments | ask | show | jobs | submit login

Also more to your point on REPL - do you know of community docs of how to use the repl more effectively? I got the basics down but really want to see how a wizard does it.



I think if you only want to see how wizards do it, you'll have to fully master emacs. As a non-wizard and vim-forever guy, who only occasionally writes Clojure for hobby projects, here's my advice.

For a long time I got by with creating a split-screen terminal with 'screen', and then used vim-slime (https://technotales.wordpress.com/2007/10/03/like-slime-for-...). It doesn't have to be split, I just like it that way, but the idea is you have essentially two views talking to the same screen session. In one you launch a repl (with lein, or even a ruby/python repl if you want) and on the other half you open vim and type things like ctrl+c etc. to send fragments from vim to the repl.

More recently I've been using slimv (https://kovisoft.bitbucket.io/tutorial.html and https://github.com/kovisoft/slimv -- and if you want my three vimrc prefs http://pastebin.com/VjwrEJJQ) after using it for Lisp, which uses swank, and found I could also do some of this for Clojure's repl (https://github.com/technomancy/swank-clojure). Unfortunately it's kind of outdated, that's not where the community is going (and I haven't really bothered to figure out exactly where that is, though that project's readme gives hints, nor have I really tried Fireplace recently enough to say if I still dislike it). But it works for me, for now, unless I want to use ClojureScript. I'd say give it a shot, you might like it.


vim-fireplace is much improved. I had been using a heavily hacked version matched to my own preferences for years but recently upgraded.

What you really want is just to run

    lein repl 
in your repository and then fire up another terminal and edit code with Vim. Then you should send whole top-level forms to the repl with :Eval from Vim and it should just work. You can then test them in the repl. (I alias C-c C-c to :Eval (:no <C-c><C-c> :Eval<cr>) because I'm used to the old vim-slime)

And it should all work automatically. With the new versions of vim-fireplace it does just work automatically.

I'll write a 'process-data function in Vim, send it with :Eval, and then test it in the repl with (process-data {:some "data", :more "other data"}) and it all just works. There's a little reading up on namespaces necessary once your projects get complicated, but it works on a bare repl right out of the box, too.


With slimv I don't even have to run lein repl, it'll run it for me (well, 'lein swank') if it hasn't already so long as I'm somewhere with a project.clj. What I don't like about having my repl and editor separate is that it's harder to get or search values from the repl back into the editor. With slimv the repl is literally just another vim window/tile so it's easy to swap over, grab a value or search history, swap back, or enter interactive mode and type stuff.

Does vim-fireplace easily let you replace forms with values (or macroexpands) or evaluate a form and have its value put somewhere? By default slimv lets you save the expression you're evaluating (which is useful for testing things) but I think I'd have to set something custom up if I wanted it to store the value somewhere or replace the just-evaluated expression. If vim-fireplace did that out of the box I'd probably consider it again. I know emacs can do it, watching people perform/livecode with Overtone et al. is instructive.

Other things I appreciate about slimv are when I type "(defn " I see a nice helper below saying "(defn [name doc-string? attr-map... prepost-map? body) + attr-map?])", this applies to everything. If I type ",s" on any symbol it'll show me the (doc) for that symbol, ",h" takes me to the online clojure docs. When I type tab it auto-suggests core functions, presumably through standard omnicomplete features though. (Edit: another useful thing, I can simply trace/untrace function calls with ",t".) Does vim-fireplace support all/any of that out of the box? It sounds like it supports my "screen" flow just fine these days but what else does it give me?


A search for "clojure repl" on youtube will bring up lots of examples.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: