status-react/doc/IDE_SETUP.md

4.7 KiB

Using IntelliJ IDEA and Cursive

Install Cursive

See https://cursive-ide.com/userguide/index.html

Getting Cursive to understand status-react

I get a lot of cannot be resolved

Are you getting problems where you get a lot of cannot be resolved on everything?

See https://cursive-ide.com/userguide/macros.html

  • opt+enter (on macOS)
  • resolve defview as fn and letsubs as let
  • move selection on resolve and hit enter
  • and select defn for defview and let for letsubs

REPL!

Connecting to REPL to IntelliJ

I had a number of problems connecting to REPL, the solution is as follows:

At the top of IntelliJ IDEA click on the Add Configuration... option:

This will load the following menu:

Click on the + icon in the top left corner of the menu.

Select Clojure REPL > Remote

Which will load the following menu

Enter the below options:

  • Name = status-react
  • Display Name = status-react
  • Connection type = nREPL
  • Connection details
    • Host = 127.0.0.1
    • Port = 7888

Press OK

Now the below option will be visible. Press the green run button

You should now see an dialog with the following message:

Connecting to remote nREPL server...
Clojure 1.10.1

To confirm you have a working connection with REPL enter the following command in the input box below the output:

(prn 1)

Which should output

(prn 1)
1
=> nil

Or

prn 1

Which should output

prn 1
=> 1
=> #function[clojure.core/prn]

See below:

Connecting REPL and IntelliJ to status-react

The important next step is telling REPL the context in which to interact with the code.

Do the following:

Ensure you have 3 terminals running the following

  • make run-clojure
  • make run-metro
  • make run-ios

// TODO Add the details of selecting the

(shadow/watch :mobile)
(shadow/repl :mobile)
  • switch clj to cljs
  • You do need to switch it manually

Connecting Cursive / IntelliJ IDEA to REPL Problems

I can connect to REPL inside the IDE, but the code doesn't seem to be able to send to REPL. But when trying to load any code into REPL I get a Cannot load Clojure form into ClojureScript REPL.

My process:

Open IDEA, not yet connected to REPL and not running a terminal with make run-clojure.

Attempting to connect to REPL without make run-clojure gives the expected error. After a terminal is running make run-clojure, connection works fine.

Entering simple functions gives a response.

However trying to do any thing REPL-ly with the code always gives a "Cannot load Clojure form into ClojureScript REPL" error.


Things I've also tried

I've done some Googling to see what could be going wrong.

https://github.com/cursive-ide/cursive/issues/1285 This issue suggests switching the file to cljc which I did out of curiosity, it connects better but it doesn't really work.

Obviously this isn't ideal even if it worked perfectly, I presume that the file types are important and converting them back and forth is a terrible work flow.

I tried converting the files to clj, just to see if that helped, which gave an interesting error:

Loading src/status_im/reloader.clj... 
Syntax error (FileNotFoundException) compiling at (src/status_im/reloader.clj:1:1).
Could not locate status_im/ui/components/react__init.class, status_im/ui/components/react.clj or status_im/ui/components/react.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.