Launch cljs nREPL connected to lein project template - clojure

I have created a ClojureScript project using:
lein new re-frame my-project
I've then opened it in IntelliJ using Cursive. In the terminal after typing lein dev, it prompts me with the message:
shadow-cljs - HTTP server available at http://localhost:8280
shadow-cljs - server version: 2.8.52 running at http://localhost:9630
shadow-cljs - nREPL server started on port 8777
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (203 files, 1 compiled, 0 warnings, 3.65s)
I can open the server using the link which directs me to a REPL, but not the nREPL connected to the browser. Following their documentation I type shadow-cljs clj-repl in to another terminal, which opens a REPL but not one that is connected to my browser or project. If I type (js/alert "hi m8") in to the REPL it responds:
Syntax error compiling at (REPL:2:1).
No such namespace: js
My question is, is how do I use the nREPL it says has started and preferably how do I access it in the integrated REPL in IntelliJ?
Thanks.
Update
Have got it working as below but if anyone knows how to get it working here in Cursive / IntelliJ:
That would be super.

The nREPL connection will always start out in Clojure mode. You can switch it to use CLJS by calling (shadow.cljs.devtools.api/repl :app) and return to Clojure mode via :cljs/quit.
You should however be connecting to a "Clojure REPL" -> "Remote" and then "localhost" with port 8777. This is configured as the default in the re-frame template via shadow-cljs.edn :nrepl {:port 8777}.
The screenshot you posted looks like you connected to the random port lein created. This will also work but requires additional configuration for the nREPL middleware.

I figured it. You have to use shadow-cljs cljs-repl app in another terminal.

Related

Can `lein ring server` command have other params?

I would like to start a server like this:
lein ring server 3000 local
lein ring server 3000 test
where local or test could be read by my app to run with different env. How can I do that?
Your use-case is exactly what Leiningen profiles are for. For example
lein with-profile test ring server

How to compile namespace in remote REPL

I have a problem compiling .clj files which reside in a project where I run the nREPL server process:
I've created a new project using lein new xxx.
In the project folder I started up an nREPL by lein repl.
In another terminal window I started a client lein repl :connect localhost:12345/repl.
I created a simple namespace file and saved it inside the project in the appropriate location:
(ns remote.one)
(def foo 42)
Now on the client terminal I called this function
(compile 'remote.one)
I've got the below exception:
CompilerException java.lang.ClassNotFoundException: remote.one, compiling:(C:\Users\xxx\AppData\Local\Temp\form-init2429492334116477513.clj:1:1)
Now I would have expected the compile call to be executed in the server not on the client. Can it be done at all?
Thanks
I just tried it and it worked for me. What happened the first time I tried it was that I missed a step: setting the current directory as the project's. I see that this step is also missing from your description, maybe that's the reason it doesn't work in your case.
Create a new project using lein new remote.
Change the current directory cd remote.
Start the nREPL server from the project folder with lein repl :headless (which I realize now is also different from your description).
Open a new console and start the nREPL client lein repl :connect localhost:port/repl in ~/..
Create the file for the ns in ~/remote/src/remote/one.clj.
From the client evaluate (compile 'remote.one).
(Using Leiningen 2.3.4 on Java 1.7.0 Java HotSpot(TM) 64-Bit Server VM and Clojure 1.5.1).

:repl-options dont reflect in the ritz nrepl client in emacs

I am using the :repl-options key in my project.clj to load default options when I start repl using lein2 repl.
I have added ritz plugins to my project.clj and ~/.lein, and once I start the repl using -
a) lein2 repl
and then connect to it using
b) M-x nrepl RET Host: localhost RET Port: 5332 (Port number on which nrepl started in the first step)
The ns that I load using :repl-options are avalaible in the repl that starts using lein2 repl, however they are not avalaible in the client started using M-x nrepl.
Any ideas on how do I get them in the client started by M-x nrepl too ?
Frankly I think that it is best to ask Leiningen related questions on its mailing list. I had an issue with Leiningen recently and Phil Hagelberg, developer of the tool, responded almost instantly.
You could also ask about https://stackoverflow.com/questions/12493003/unmateched-delimiter-exception-but-still-able-to-run-code. I have similar issues with Lein2 (only in Cygwin), so maybe it will result in a bug report.

Remote builds with IntelliJ

I am having the following problem:
a) I have a UNIX build environment set up on a remote server I can ssh into
b) I have IntelliJ on Windows
What I would like to do is to edit the files through a remote connection
(similar to the functionality that exists for Emacs) and issue shell commands
such as 'make' and running simple 'test-scripts' which exist on the server..
Are the functions to do this integrated into IntelliJ or will I need a plug-in?
There is a SSH plugin for Intellij IDEA. It is available in https://plugins.jetbrains.com/idea/plugin/1203-ssh
For anyone still looking for a way to edit files remotely while running Intellij locally, version 2016.3 Ultimate Edition has a Remote Server Configuration option. It allows to access files remotely using either FTP, SFTP or FTPS.
More details on how to configure the remote servers can be found in Intellij's Help Pages.

How can I restart swank in Leiningen's interactive mode?

Let's say I'm running Leiningen in interactive mode ('lein interactive') and have started a Swank Clojure server ('swank'). Now I want to kill/restart the Swank server without killing Leiningen as well. How can I do this? Is this even possible?
So far I've just been using Ctrl-C to kill both, which doesn't make Leiningen's interactive mode all that useful for me since I may as well have just ran 'lein swank' to begin with.
If you are using Slime, you can call ,rest which is bound to (restart-inferior-lisp). This will restart your swank session.
This isn't implemented yet. However, the interactive task is intended for people who don't use swank. Swank already keeps a JVM open for your project, so that kind of defeats the purpose of the interactive task.