Last active
December 24, 2015 07:49
-
-
Save bsenduran/db9ce5b0289bd692361b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setup a clojure project | |
------------------------- | |
* Use `mvn archetype:generate` to create a project. (archetype id 845 for sample clojure project) | |
* add the nrepl dependency | |
<dependency> | |
<groupId>org.clojure</groupId> | |
<artifactId>tools.nrepl</artifactId> | |
<version>0.2.0-beta9</version> | |
</dependency> | |
[https://github.com/talios/clojure-maven-plugin] | |
(to upgrade the version add the following in to the pom.xml | |
<repository> | |
<id>clojars.org</id> | |
<url>http://clojars.org/repo</url> | |
</repository> | |
) | |
* make sure the clojure maven plug-in version is above 1.3.14 | |
* adding support for auto complete | |
<dependency> | |
<groupId>clojure-complete</groupId> | |
<artifactId>clojure-complete</artifactId> | |
<version>0.2.3</version> | |
<scope>test</scope> | |
<exclusions> | |
<exclusion> | |
<artifactId>clojure</artifactId> | |
<groupId>org.clojure</groupId> | |
</exclusion> | |
</exclusions> | |
</dependency> | |
setup nrepl in emacs | |
---------------------- | |
* Install emacs. | |
* add the following to ~/.emacs.d/init.el | |
(require 'package) | |
(add-to-list 'package-archives | |
'("marmalade" . "http://marmalade-repo.org/packages/")) | |
(package-initialize) | |
* load it with `M-x eval-buffer` (M-x: meta+x i.e alt+x) | |
* install nrepl with, `M-x package-install [RET] nrepl [RET]` | |
(RET-enter) [https://github.com/clojure-emacs/nrepl.el] | |
* toenable auto complete and paredit, add the following entry to the ~/.emacs.d/init.el | |
======================================================================================== | |
(defvar my-packages '(starter-kit | |
starter-kit-lisp | |
starter-kit-bindings | |
starter-kit-eshell | |
clojure-mode | |
clojure-test-mode | |
auto-complete | |
nrepl | |
ac-nrepl)) | |
(dolist (p my-packages) | |
(when (not (package-installed-p p)) | |
(package-install p))) | |
(add-to-list 'load-path "~/emacs.d/paredit/paredit.el") | |
(add-hook 'nrepl-repl-mode-hook 'paredit-mode) | |
(require 'ac-nrepl) | |
(add-hook 'nrepl-mode-hook 'ac-nrepl-setup) | |
(add-hook 'nrepl-interaction-mode-hook 'ac-nrepl-setup) | |
(eval-after-load "auto-complete" | |
'(add-to-list 'ac-modes 'nrepl-mode)) | |
(defun set-auto-complete-as-completion-at-point-function () | |
(setq completion-at-point-functions '(auto-complete))) | |
(add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function) | |
(add-hook 'nrepl-mode-hook 'set-auto-complete-as-completion-at-point-function) | |
(add-hook 'nrepl-interaction-mode-hook 'set-auto-complete-as-completion-at-point-function) | |
(define-key nrepl-interaction-mode-map (kbd "C-c C-d") 'ac-nrepl-popup-doc) | |
(setq initial-scratch-message "") | |
======================================================================================== | |
* create the ~/emacs.d/paredit/paredit.el file with following content mention in the url | |
http://mumble.net/~campbell/emacs/paredit.el | |
Connect to nrepl | |
----------------- | |
*execute the following command in the project root | |
`mvn clojure:nrepl` | |
*connect to nrepl in emacs by | |
`M-x nrepl` | |
host- 127.0.0.1, port-4005 | |
* enable `paredit-mode` and `auto-complete-mode` | |
(M-x paredit-mode [RET]) (M-x auto-complete-mode [RET]) | |
samples | |
------------------------ | |
> (import 'java.util.Random) | |
[in clojure code use `:import java.util.Random`] | |
> (.nextInt (new Random)) or (.nextInt (Random.)) where the `.` in the Random. is a reader macro |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment