Software
These are the instructions for installing and getting up and running
IntelliJ IDEA with the La Clojure
plugin. It should work on Windows, Mac, and most modern Linux
distributions.
Installing IntelliJ IDEA
Installing La Clojure Plugin
-
When IDEA starts, in the Welcome! page follow the
Open Plugin Manager link, or select from the main
menu File/Settings and under IDE
Settings select Plugins.
-
Once the Plugins window is open, select the
Available tab, and then search and select the name
La Clojure. Click on the Download and
Install icon (a small floppy disk with a green arrow).
When it finishes, press the OK button. You will be
requested to restart IDEA in order to conclude the installation.
Creating the JDK and Clojure Libraries
-
Create a folder in your file system called
clojure1.2.0
. Download and move into this folder the
following two files:
clojure-1.2.0.jar and
clojure-contrib-1.2.0.jar.
-
Open IDEA. In the main menu, select File/Project
Structure.
-
Under Platform Settings, select
SDKs. Click on the Add New SDK
icon (a yellow square with a plus sign), choose the
JSDK option and select the path of your JDK
installation (for example:
/usr/local/java/jdk1.6.0_23
).
-
Under Platform Settings, select Global
Libraries. Click on the New Global Library
icon (the same yellow square with a plus sign). Replace the name of
the library from Unnamed to Clojure
1.2.0. Press the Attach Jar Directories...
button and select the
clojure1.2.0
path you created in
the first step. Press the OK button.
Creating a Clojure Project
-
Open IDEA. From the Welcome! page, follow the
Create New Project link, or from the main menu
select File/New Project....
-
In the first dialog window, select the Create project from
scratch and press the Next button.
-
In the next dialog window, type a name for your project and take
note of the project files location. You should leave the remaining
options with their default values and press the
Next button.
-
In the next dialog window, select Create source
directory and specify the name of the source directory (the
default
src
is fine). Press Next
button.
-
In the final dialog window, check the Clojure
checkbox. In Clojure Settings select version
1.2. In Libraries select
Set up library later. Press the
Finish button and wait until the project creation
process terminates (it might take a few minutes).
-
In the Project window select with the secondary
mouse button the newly created project to obtain a pop-up menu.
Select Open Module Settings. Under Project
Settings, select Modules and choose the
Dependencies tab. Press the Add...
button and select Library..., then select
Clojure 1.2.0 and press the Add Selected
button. Finally press the OK button.
Opening the REPL (Read-Print-Eval Loop)
-
Once a Clojure project has been created, from the IDEA main menu
select Tools/Start Clojure Console to open a REPL.
-
Type any Clojure expressions at the REPL. You can repeat any
previously typed expression by pressing the up and down keys and
navigating through the command history.
Adding Clojure Source Files to the Project
-
In the Project window, expand the project by
clicking the plus sign in front of the project name. Select with the
secondary mouse button the
src
folder and choose
New/Clojure File. When typing the name of a source
file, the .clj
extension will be added if it was not
provided.
-
To load the file into the REPL, select from the main menu
Tools/Clojure REPL/Load file to REPL.
Useful Tips
-
In the editor (and the REPL) you can use Ctrl-Space
for code completion. Press the tab key to select
the first option that appears.
-
In the editor (and the REPL), you can use Ctrl-Q to
obtain context sensitive documentation.
-
In the editor, you can reformat your code using the standard Clojure
style and conventions. From the main menu, select
Code/Reformat Code....