forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-clojure.el
75 lines (56 loc) · 2.96 KB
/
init-clojure.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Slime with Clojure
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Use technomancy's bag of fancy clojure/slime tricks
(eval-after-load 'slime
'(progn
(require 'durendal)
(durendal-enable t)
(durendal-disable-slime-repl-font-lock)))
(defun slime-clojure-repl-setup ()
"Some REPL setup additional to that in durendal."
(when (string-equal (slime-lisp-implementation-name) "clojure")
(when (slime-inferior-process)
(message "Setting up repl for clojure")
(slime-redirect-inferior-output))
(set-syntax-table clojure-mode-syntax-table)
(setq lisp-indent-function 'clojure-indent-function)
(let (font-lock-mode)
(clojure-mode-font-lock-setup))))
(add-hook 'slime-repl-mode-hook 'slime-clojure-repl-setup)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; nrepl with Clojure
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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))
(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)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Misc clojure tweaks
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'clojure-mode-hook 'sanityinc/lisp-setup)
(defmacro defclojureface (name color desc &optional others)
`(defface ,name '((((class color)) (:foreground ,color ,@others))) ,desc :group 'faces))
(defclojureface clojure-parens "DimGrey" "Clojure parens")
(defclojureface clojure-braces "#49b2c7" "Clojure braces")
(defclojureface clojure-brackets "SteelBlue" "Clojure brackets")
(defclojureface clojure-keyword "khaki" "Clojure keywords")
(defclojureface clojure-java-call "#4bcf68" "Clojure Java calls")
(defclojureface clojure-special "#b8bb00" "Clojure special")
(defclojureface clojure-double-quote "#b8bb00" "Clojure special" (:background "unspecified"))
(defun tweak-clojure-syntax ()
(dolist (x '((("#?['`]*(\\|)" . 'clojure-parens))
(("#?\\^?{\\|}" . 'clojure-brackets))
(("\\[\\|\\]" . 'clojure-braces))
((":\\w+#?" . 'clojure-keyword))
(("#?\"" 0 'clojure-double-quote prepend))
(("nil\\|true\\|false\\|%[1-9]?" . 'clojure-special))
(("(\\(\\.[^ \n)]*\\|[^ \n)]+\\.\\|new\\)\\([ )\n]\\|$\\)" 1 'clojure-java-call))
))
(font-lock-add-keywords nil x)))
(add-hook 'clojure-mode-hook 'tweak-clojure-syntax)
(eval-after-load 'gist
'(add-to-list 'gist-supported-modes-alist '(clojure-mode . ".clj")))
(provide 'init-clojure)