Today, I will show you how to run nrepl server and connect emacs to it.
1. Create empty folder helloproject
2. Create file deps.edn in helloproject folder and put here the following content:
Here we import library clj-time from Maven repo, and import extra deps under alias :repl
3. Now create src folder in helloproject folder,.i.e helloproject/src
4. Create file hello.clj in helloproject/src folder and put here the following content:
5. Now we are ready to run repl. Change dir to helloproject and run command: clj -R:repl
The clj parameter -R:repl is important to load extra deps. If you have several aliases then you should list them comma separated, i.e. clj -R:alias1,alias2
After run command clj -R:repl you should see the prompt:
6. Now we may start nrepl server. Enter the following two commands in repl:
(require '[clojure.tools.nrepl.server :refer [start-server]] '[cider.nrepl :refer [cider-nrepl-handler]])
(let [port (or (some-> (first *command-line-args*) (java.lang.Long/parseLong)) 7888)] (start-server :port port :handler cider-nrepl-handler) (println "Started nREPL on port" port))
7. After successful nrepl server start you may open helloproject/src/hello.clj in your favourite editor and connect to remote repl.
In Emacs: M-x cider-connect
then enter: localhost and 7888
1. Create empty folder helloproject
2. Create file deps.edn in helloproject folder and put here the following content:
Here we import library clj-time from Maven repo, and import extra deps under alias :repl
3. Now create src folder in helloproject folder,.i.e helloproject/src
4. Create file hello.clj in helloproject/src folder and put here the following content:
5. Now we are ready to run repl. Change dir to helloproject and run command: clj -R:repl
The clj parameter -R:repl is important to load extra deps. If you have several aliases then you should list them comma separated, i.e. clj -R:alias1,alias2
After run command clj -R:repl you should see the prompt:
Clojure 1.9.0
user=>
6. Now we may start nrepl server. Enter the following two commands in repl:
(require '[clojure.tools.nrepl.server :refer [start-server]] '[cider.nrepl :refer [cider-nrepl-handler]])
(let [port (or (some-> (first *command-line-args*) (java.lang.Long/parseLong)) 7888)] (start-server :port port :handler cider-nrepl-handler) (println "Started nREPL on port" port))
7. After successful nrepl server start you may open helloproject/src/hello.clj in your favourite editor and connect to remote repl.
In Emacs: M-x cider-connect
then enter: localhost and 7888