-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup-clojure.el
93 lines (70 loc) · 2.56 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
92
93
;;; setup-clojure.el --- Clojure editing
;;; Commentary:
;; Clojure and Cider customizations
;;; Code:
(require 'clojure-mode-extra-font-locking)
(require 'flycheck-clj-kondo)
(require 'clj-refactor)
;;;;
;; 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)
;; syntax highlighting for midje
(add-hook 'clojure-mode-hook
(lambda ()
(font-lock-add-keywords
nil
'(("(\\(facts?\\)"
(1 font-lock-keyword-face))
("(\\(background?\\)"
(1 font-lock-keyword-face))))
(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.*$" . clojurescript-mode))
(add-to-list 'auto-mode-alist '("lein-env" . enh-ruby-mode))
(defun cider-refresh ()
"Cider refresh."
(interactive)
(cider-interactive-eval (format "(user/reset)")))
(defun cider-user-ns ()
"Cider set user namespace."
(interactive)
(cider-repl-set-ns "user"))
(eval-after-load 'cider
'(progn
(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)))
(defun my-clojure-mode-hook ()
"Clojure refactor support."
(clj-refactor-mode 1)
(yas-minor-mode 1) ; for adding require/use/import statements
;; This choice of keybinding leaves cider-macroexpand-1 unbound
(cljr-add-keybindings-with-prefix "C-c C-m"))
(add-hook 'clojure-mode-hook #'my-clojure-mode-hook)
(provide 'setup-clojure)
;;; setup-clojure.el ends here