I’m just starting out with Clojure. So far I’ve edited .clj files and executed them by running lein repl
, (load-file "test.clj")
and (foo)
. This worked so far.
Mind I haven’t created a leiningen project. I simply use lein repl
because the standard repl doesn’t even support cursor up to recall the last command.
Now I want to up my game a bit and run clojure from within neovim. fireplace was suggested in the first spot both on clojure.org and on clojure-doc.org. Thus I’ve installed that.
Now consider this code:
(ns leintest.testns)
(defn foo [] "foo")
(foo)
(+ 2 3)
which I put into leintest/src/leintest/testns/test.clj
. As the file structure suggest, this is now a leiningen project created with lein new app leintest
.
However, nothing works. Sometimes I could get (+ 2 3)
to print 5 when I run :Eval with the cursor on it, but not even that worked when I created this example. I also couldn’t run (foo)
in the repl. The testns
namespace simply isn’t there.
Funny thing, when I load test.clj
into the repl outside of a leiningen project, I can actually call (leintest.testns/foo)
.
While the README on github for fireplace isn’t exactly short, I can’t shake the feeling that it is not aimed at beginners like me. Most of it simply doesn’t make sense to me.
Is there anywhere a beginner friendly guide how to get started with fireplace? I’m not hellbend on fireplace though. I simply went with it because it was the first suggestion. If there is another plugin that is more beginner friendly I’ll gladly swap for it.
Here are some questions:
I run lein repl
from a separate terminal. Isn’t there a way to start the repl from within vim?
How can I get (foo)
and (+ 2 3)
to be evaluated with :Eval (or perhaps another method)?
Do I even need to have (foo)
in the file just in order to run the function foo?
How does reloading work? I sometimes have the feeling that my edits have no effect. But when I kill the repl and restart it, I seem to get some reaction to my edits. I doubt that this is the appropriate workflow.
I would also expect that since I have a repl open in the leiningen project, I would be able to evaluate my functions directly in the repl. That never worked for me. Only when I loaded the file manually outside of a leiningen project.