Added ToC, Tidied Troubleshooting, Added images to avoid future 404s

Removed superfluous check

Adjusted images to be 50% the page width

Image width 75%

Finished off REPL section

Signed-off-by: Samuel Hawksby-Robinson <samuel@samyoul.com>
This commit is contained in:
Samuel Hawksby-Robinson 2021-03-24 11:33:58 +00:00
parent a4836120e6
commit f970834536
No known key found for this signature in database
GPG Key ID: AD6D836B165CCDA7
13 changed files with 34 additions and 57 deletions

View File

@ -1,5 +1,14 @@
# Using IntelliJ IDEA and Cursive
## Table of Contents
- [Install Cursive](#install-cursive)
- [Getting Cursive to understand `status-react`](#getting-cursive-to-understand-status-react)
- [I get a lot of `cannot be resolved`](#i-get-a-lot-of-cannot-be-resolved)
- [REPL!](#repl)
- [Connecting to REPL to IntelliJ](#connecting-to-repl-to-intellij)
- [Connecting REPL and IntelliJ to `status-react`](#connecting-repl-and-intellij-to-status-react)
## Install Cursive
See https://cursive-ide.com/userguide/index.html
@ -10,13 +19,13 @@ See https://cursive-ide.com/userguide/index.html
- https://gist.github.com/Samyoul/f71a0593ba7a12d24dd0d5ef986ebbec
- Right click and "add as leiningen project"
![](https://notes.status.im/uploads/upload_32ea1a8eeb410effc24b5f3914e38627.png)
<img src="images/IDE_SETUP/1_fake_project_file.png" width=75% />
## I get a lot of `cannot be resolved`
Are you getting problems where you get a lot of `cannot be resolved` on everything?
![](https://notes.status.im/uploads/upload_73ed33ce7af35a289c88afdb01fc91b7.jpg)
<img src="images/IDE_SETUP/2_resolve.jpeg" width=75% />
See https://cursive-ide.com/userguide/macros.html
@ -33,21 +42,21 @@ 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:
![](https://notes.status.im/uploads/upload_b16dd48e03ef4cc98c53cc896a532f90.png)
<img src="images/IDE_SETUP/3_REPL_1.png" width=75% />
This will load the following menu:
![](https://notes.status.im/uploads/upload_0f50285b745a00cfe3cab3c4af415d21.png)
<img src="images/IDE_SETUP/4_REPL_2.png" width=75% />
Click on the `+` icon in the top left corner of the menu.
Select `Clojure REPL > Remote`
![](https://notes.status.im/uploads/upload_0d890d5ed6e2d8d48d31cab7fa99d9e9.png)
<img src="images/IDE_SETUP/5_REPL_3.png" width=75% />
Which will load the following menu
![](https://notes.status.im/uploads/upload_563dce472426f1f691a55713556a9b36.png)
<img src="images/IDE_SETUP/6_REPL_4.png" width=75% />
Enter the below options:
@ -58,14 +67,14 @@ Enter the below options:
- Host = 127.0.0.1
- Port = 7888
![](https://notes.status.im/uploads/upload_88ed1d279c314d2264405f15a5e56433.png)
<img src="images/IDE_SETUP/7_REPL_5.png" width=75% />
Press `OK`
Now the below option will be visible.
Press the green run button
![](https://notes.status.im/uploads/upload_d3c538110f5cc21770311b288ac382d7.png)
<img src="images/IDE_SETUP/8_REPL_6.png" width=75% />
You should now see an dialog with the following message:
@ -88,23 +97,9 @@ Which should output
=> nil
```
Or
```shell
prn 1
```
Which should output
```shell
prn 1
=> 1
=> #function[clojure.core/prn]
```
See below:
![](https://notes.status.im/uploads/upload_0f39b27d0ad287db7a5f1f180f9c55b5.png)
<img src="images/IDE_SETUP/9_REPL_7.png" width=75% />
### Connecting REPL and IntelliJ to `status-react`
@ -116,55 +111,37 @@ Ensure you have 3 terminals running the following
- `make run-clojure`
- `make run-metro`
- `make run-ios`
- `make run-ios` / `make run-android`
[See the STARTING GUIDE for details](STARTING_GUIDE.md#development)
Next go back to the REPL input and enter the following commands:
// TODO Add the details of selecting the
```clojure
(shadow/watch :mobile)
(shadow/repl :mobile)
```
- switch clj to cljs
- You do need to switch it manually
### Connecting Cursive / IntelliJ IDEA to REPL Problems
See Below
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`.
<img src="images/IDE_SETUP/10_REPL_8.png" width="75%" />
My process:
Which should switch the clj file type target to cljs as shown above
Open IDEA, not yet connected to REPL and not running a terminal with `make run-clojure`.
Finally you are ready to test REPL.
![](https://notes.status.im/uploads/upload_a2abb27acbee62a0ca9ffdc41d2219dc.png)
Create a sample function to evaluate something simple like `(prn "I'm working")`, move your cursor to one of the outer parentheses. Right or `control` click and select the `REPL` option. From there select `Sync files in REPL` and then `Send '...' to REPL'`.
Attempting to connect to REPL without `make run-clojure` gives the expected error. After a terminal is running `make run-clojure`, connection works fine.
<img src="images/IDE_SETUP/11_REPL_9.png" width="75%" />
Entering simple functions gives a response.
Alternatively you can use the shortcut commands `⇧⌘M` to sync your files and `⇧⌘P` to send the statement to REPL. You may also need to switch the REPL namespace to match the current file, which can be done manually from the dialogue box or using the `⇧⌘N` shortcut key.
![](https://notes.status.im/uploads/upload_9b2848993feb4181ad8fee96fc0dd6e9.png)
Following the above should give you the below result:
However trying to do any thing REPL-ly with the code always gives a "*Cannot load Clojure form into ClojureScript REPL*" error.
<img src="images/IDE_SETUP/12_REPL_10.png" width="75%" />
![](https://notes.status.im/uploads/upload_d29b3ded54afdfddf0a2cb09bfdbd121.png)
![](https://notes.status.im/uploads/upload_c07a7805e1e7c954e3d3698063410bb5.png)
🎉 Tada! Working! 🎉
---
### 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.
![](https://notes.status.im/uploads/upload_79bca0edc0c1841a7cbdcec50a4f90eb.png)
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:
```bash=
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.
```
For additional details on issues you may face when setting up REPL with Cursive [see this document](https://notes.status.im/9Gr7kqF8SzC_SmYK0eB7uQ?view#Connecting-Cursive--IntelliJ-IDEA-to-REPL-Problems)

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB