-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-clojure.el
91 lines (73 loc) · 3.25 KB
/
setup-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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
;;;;
;; Clojure
;;;;
;; Enable paredit for Clojure
;;(add-hook 'clojure-mode-hook 'enable-paredit-mode)
;; This is useful for working with camel-case tokens, like names of
;; Java classes (e.g. JavaClassName)
(add-hook 'clojure-mode-hook 'subword-mode)
;; A little more syntax highlighting
(require 'clojure-mode-extra-font-locking)
;; syntax hilighting for midje
(add-hook 'clojure-mode-hook
(lambda ()
(setq inferior-lisp-program "lein repl")
(font-lock-add-keywords
nil
'(("(\\(facts?\\)"
(1 font-lock-keyword-face))
("(\\(background?\\)"
(1 font-lock-keyword-face))))
;; (local-set-key (kbd "C-x C-e") 'cider-eval-defun-at-point);; like elisp
;; (local-set-key (kbd "C-c C-c") 'cider-eval-last-sexp);; like slime
(define-clojure-indent (fact 1))
(define-clojure-indent (facts 1))))
;(rainbow-delimiters-mode)))
;;;;
;; Cider
;;;;
;; provides minibuffer documentation for the code you're typing into the repl
(add-hook 'cider-mode-hook 'eldoc-mode)
;; go right to the REPL buffer when it's finished connecting
(setq cider-repl-pop-to-buffer-on-connect t)
;; When there's a cider error, show its buffer and switch to it
(setq cider-show-error-buffer t)
(setq cider-auto-select-error-buffer t)
;; Where to store the cider history.
(setq cider-repl-history-file "~/.emacs.d/cider-history")
;; Wrap when navigating history.
(setq cider-repl-wrap-history t)
;; enable paredit in your REPL
;; (add-hook 'cider-repl-mode-hook 'paredit-mode)
;; Use clojure mode for other extensions
(add-to-list 'auto-mode-alist '("\\.edn$" . clojure-mode))
(add-to-list 'auto-mode-alist '("\\.boot$" . clojure-mode))
;;(add-to-list 'auto-mode-alist '("\\.cljs.*$" . clojure-mode))
(add-to-list 'auto-mode-alist '("lein-env" . enh-ruby-mode))
;; key bindings
;; these help me out with the way I usually develop web apps
(defun cider-start-http-server ()
(interactive)
(cider-load-current-buffer)
(let ((ns (cider-current-ns)))
(cider-repl-set-ns ns)
(cider-interactive-eval (format "(println '(def server (%s/start))) (println 'server)" ns))
(cider-interactive-eval (format "(def server (%s/start)) (println server)" ns))))
(defun cider-refresh ()
(interactive)
(cider-interactive-eval (format "(user/reset)")))
(defun cider-user-ns ()
(interactive)
(cider-repl-set-ns "user"))
(eval-after-load 'cider
'(progn
(define-key clojure-mode-map (kbd "C-c C-v") 'cider-start-http-server)
(define-key clojure-mode-map (kbd "C-M-r") 'cider-refresh)
(define-key clojure-mode-map (kbd "C-c u") 'cider-user-ns)
(define-key cider-mode-map (kbd "C-c u") 'cider-user-ns)
;; didn't work; ALSO DIDNT WORK WHEN I hacked ~/.emacs.d/elpa/cider../cider-repl.el L@1604 L@1619 and ran (byte-recompile-directory package-user-dir nil 'force) and restarted
;; worked when I hacked ~/.emacs.d/elpa/cider../cider-mode.el L@496 L@497 and ran (byte-recompile-directory package-user-dir nil 'force) and restarted
;; like elisp
(define-key clojure-mode-map (kbd "C-x C-e") 'cider-eval-defun-at-point)
;; like slime
(define-key clojure-mode-map (kbd "C-c C-c") 'cider-eval-last-sexp)))