Skip to content

Using IntelliJ Cursive with Arcadia

Folcon edited this page Sep 26, 2021 · 20 revisions

An example project to get started, if anyone has any feedback for improvements please create an issue!: https://github.com/Folcon/arcadia-example-project

GETTING AUTOCOMPLETE WORKING

GIVEN...


  • IntelliJ and Cursive are installed
  • Unity is installed and you have set up the project according to the Usage guide. You now have an Assets folder with Arcadia in it.
    • For demonstration purposes, I have named my project CursiveArcadia in the examples that follow

WHEN...


  1. In IntelliJ, File > Open... Select your Unity Project Select your project's containing folder
  2. In the Project Panel on the left, select the Assets directory assets directory
  3. Right click, mark the directory as Sources Root Mark as sources Root
  4. Create a new Clojure Namespace within the Assets directory, name it anything you want. new namespace
  5. At the top, you'll get a warning that no Project SDK is defined. Click the suggested link, and choose the default IDE jdk (unless you have some other jdk you would prefer) setup sdk default IDE SDK

THEN...


  • To get autocompletion running against your project and its dependencies, refresh your leiningen projects (double tapping shift and searching for Refresh Leiningen Projects) or restart Intellij. You will need to do this again whenever you add new external clojure files to the project. refresh projects
  • See the magic at work! In your Clojure code, require the Arcadia project and you should see IntelliJ suggest autocompletion options for you. require arcadia function autocomplete

GETTING THE REPL WORKING

GIVEN...


  • You have completed the steps above
    • Specifically, you need to have an IntelliJ project that contains the Assets directory of your Unity Project.

WHEN...


  1. Clone the The Arcadia nREPL project into your Assets folder and, per the docs, place a .nrepl-port file into the project directory:
$ cd path/to/your/unity/project/Assets
$ git clone [email protected]:spacepluk/arcadia.nrepl.git
$ echo 7888 > arcadia.nrepl/.nrepl-port
  1. In your IntelliJ project Panel, navigate to the project.clj of the newly cloned project and right click. Select "Add as Leiningen Project" add leiningger project
  2. You'll need to create 2 new run configurations. One to start the nREPL bridge, and one to connect to it. In the toolbar, select Edit Configurations (if your toolbar isn't displayed, just google how to edit run configurations in IntelliJ) edit configurations
  3. Create your first run configuration. Select the Leiningen configuration from the drop down, ensure the settings match up with the picture shown below, and click "apply" before proceeding to the next step: select leiningen run config name it, set arguments to "run"
  4. Create your second run configuration. Select the Clojure REPL > Remote configuration from the drop down, ensure the settings match up with the picture shown below, and click "apply" remote clojure repl set to localhost on port 7888

THEN...


  • With your Unity project open, run the Start Arcadia REPL configuration, wait for it to start up, and then run your Connect to Arcadia REPL config.
  • You'll see the terminal output showing the nREPL bridge starting up (mine shows some kind of irrelevant error), and you'll see the REPL window appear on the left. Evaluate the arcadia require statement, then eval a log statement and see it show up in the Unity console! eval log statement with repl running observe output in repl window success!