2015-04-19 03:40:24 +00:00
|
|
|
(setq clojure-packages
|
2014-12-11 12:07:49 +00:00
|
|
|
'(
|
2015-04-06 03:13:00 +00:00
|
|
|
align-cljlet
|
2014-12-11 12:07:49 +00:00
|
|
|
cider
|
2015-04-05 03:25:11 +00:00
|
|
|
cider-eval-sexp-fu
|
2014-12-11 12:07:49 +00:00
|
|
|
clj-refactor
|
2015-04-06 03:13:00 +00:00
|
|
|
clojure-mode
|
|
|
|
company
|
2015-02-20 04:37:06 +00:00
|
|
|
rainbow-delimiters
|
|
|
|
subword
|
2015-04-19 03:40:24 +00:00
|
|
|
))
|
2014-12-11 12:07:49 +00:00
|
|
|
|
2015-02-24 02:58:18 +00:00
|
|
|
(defun clojure/init-align-cljlet ()
|
|
|
|
(use-package align-cljlet
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(add-hook 'clojure-mode-hook (lambda () (require 'align-cljlet)))
|
|
|
|
:config
|
|
|
|
(evil-leader/set-key-for-mode 'clojure-mode
|
2015-02-24 03:18:48 +00:00
|
|
|
"mfl" 'align-cljlet)))
|
2015-02-24 02:58:18 +00:00
|
|
|
|
2014-12-11 12:07:49 +00:00
|
|
|
(defun clojure/init-cider ()
|
|
|
|
(use-package cider
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
2014-12-17 05:58:14 +00:00
|
|
|
(setq cider-stacktrace-default-filters '(tooling dup)
|
|
|
|
cider-repl-pop-to-buffer-on-connect nil
|
2015-02-02 23:07:29 +00:00
|
|
|
cider-prompt-save-file-on-load nil
|
|
|
|
cider-repl-use-clojure-font-lock t)
|
2015-04-13 19:29:46 +00:00
|
|
|
(push "\\*cider-repl\.\+\\*" spacemacs-useful-buffers-regexp)
|
2015-02-24 01:52:49 +00:00
|
|
|
(add-hook 'clojure-mode-hook 'cider-mode)
|
2015-03-05 21:56:11 +00:00
|
|
|
(add-hook 'cider-mode-hook 'cider-turn-on-eldoc-mode)
|
|
|
|
(if dotspacemacs-smartparens-strict-mode
|
|
|
|
(add-hook 'cider-repl-mode-hook #'smartparens-strict-mode)))
|
2014-12-11 12:07:49 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-02-24 01:52:49 +00:00
|
|
|
;; add support for golden-ratio
|
2015-02-25 12:44:48 +00:00
|
|
|
(eval-after-load 'golden-ratio
|
|
|
|
'(push 'cider-popup-buffer-quit-function golden-ratio-extra-commands))
|
2015-02-24 01:52:49 +00:00
|
|
|
;; add support for evil
|
|
|
|
(push 'cider-stacktrace-mode evil-motion-state-modes)
|
|
|
|
(push 'cider-popup-buffer-mode evil-motion-state-modes)
|
2015-02-16 13:37:16 +00:00
|
|
|
|
2015-02-20 03:31:32 +00:00
|
|
|
(defun spacemacs//cider-eval-in-repl-no-focus (form)
|
|
|
|
"Insert FORM in the REPL buffer and eval it."
|
|
|
|
(let ((start-pos (point)))
|
|
|
|
(while (string-match "\\`[ \t\n\r]+\\|[ \t\n\r]+\\'" form)
|
|
|
|
(setq form (replace-match "" t t form)))
|
|
|
|
(with-current-buffer (cider-current-repl-buffer)
|
|
|
|
(insert form)
|
|
|
|
(indent-region start-pos (point))
|
|
|
|
(cider-repl-return))))
|
|
|
|
|
2015-03-14 05:46:05 +00:00
|
|
|
(defun spacemacs/cider-send-last-sexp-to-repl ()
|
2015-02-20 03:31:32 +00:00
|
|
|
"Send last sexp to REPL and evaluate it without changing
|
|
|
|
the focus."
|
|
|
|
(interactive)
|
|
|
|
(spacemacs//cider-eval-in-repl-no-focus (cider-last-sexp)))
|
|
|
|
|
2015-03-14 05:46:05 +00:00
|
|
|
(defun spacemacs/cider-send-last-sexp-to-repl-focus ()
|
2015-02-20 03:31:32 +00:00
|
|
|
"Send last sexp to REPL and evaluate it and switch to the REPL in
|
|
|
|
`insert state'."
|
|
|
|
(interactive)
|
|
|
|
(cider-insert-last-sexp-in-repl t)
|
|
|
|
(evil-insert-state))
|
|
|
|
|
2015-03-14 05:46:05 +00:00
|
|
|
(defun spacemacs/cider-send-region-to-repl (start end)
|
2015-02-24 03:09:39 +00:00
|
|
|
"Send region to REPL and evaluate it without changing
|
|
|
|
the focus."
|
2015-02-27 23:19:23 +00:00
|
|
|
(interactive "r")
|
2015-02-24 03:09:39 +00:00
|
|
|
(spacemacs//cider-eval-in-repl-no-focus
|
2015-02-27 23:19:23 +00:00
|
|
|
(buffer-substring-no-properties start end)))
|
2015-02-24 03:09:39 +00:00
|
|
|
|
2015-03-14 05:46:05 +00:00
|
|
|
(defun spacemacs/cider-send-region-to-repl-focus (start end)
|
2015-02-24 03:09:39 +00:00
|
|
|
"Send region to REPL and evaluate it and switch to the REPL in
|
|
|
|
`insert state'."
|
2015-02-27 23:19:23 +00:00
|
|
|
(interactive "r")
|
2015-02-24 03:09:39 +00:00
|
|
|
(cider-insert-in-repl
|
2015-02-27 23:19:23 +00:00
|
|
|
(buffer-substring-no-properties start end) t)
|
2015-02-24 03:09:39 +00:00
|
|
|
(evil-insert-state))
|
|
|
|
|
2015-03-14 05:46:05 +00:00
|
|
|
(defun spacemacs/cider-send-function-to-repl ()
|
2015-02-20 03:31:32 +00:00
|
|
|
"Send current function to REPL and evaluate it without changing
|
|
|
|
the focus."
|
|
|
|
(interactive)
|
|
|
|
(spacemacs//cider-eval-in-repl-no-focus (cider-defun-at-point)))
|
|
|
|
|
2015-03-14 05:46:05 +00:00
|
|
|
(defun spacemacs/cider-send-function-to-repl-focus ()
|
2015-02-20 03:31:32 +00:00
|
|
|
"Send current function to REPL and evaluate it and switch to the REPL in
|
|
|
|
`insert state'."
|
|
|
|
(interactive)
|
|
|
|
(cider-insert-defun-in-repl t)
|
|
|
|
(evil-insert-state))
|
|
|
|
|
2015-03-14 05:46:05 +00:00
|
|
|
(defun spacemacs/cider-send-ns-form-to-repl ()
|
2015-02-20 03:31:32 +00:00
|
|
|
"Send buffer's ns form to REPL and evaluate it without changing
|
|
|
|
the focus."
|
|
|
|
(interactive)
|
|
|
|
(spacemacs//cider-eval-in-repl-no-focus (cider-ns-form)))
|
|
|
|
|
2015-03-29 13:48:28 +00:00
|
|
|
(defun spacemacs/cider-send-ns-form-to-repl-focus ()
|
2015-02-20 03:31:32 +00:00
|
|
|
"Send ns form to REPL and evaluate it and switch to the REPL in
|
|
|
|
`insert state'."
|
|
|
|
(interactive)
|
|
|
|
(cider-insert-ns-form-in-repl t)
|
|
|
|
(evil-insert-state))
|
|
|
|
|
2015-03-14 05:46:05 +00:00
|
|
|
(defun spacemacs/cider-send-buffer-in-repl-and-focus ()
|
2015-02-20 03:31:32 +00:00
|
|
|
"Send the current buffer in the REPL and switch to the REPL in
|
|
|
|
`insert state'."
|
|
|
|
(interactive)
|
|
|
|
(cider-load-buffer)
|
|
|
|
(cider-switch-to-repl-buffer)
|
|
|
|
(evil-insert-state))
|
|
|
|
|
2015-05-03 17:46:19 +00:00
|
|
|
(defun spacemacs/cider-test-run-focused-test ()
|
|
|
|
(interactive)
|
|
|
|
(cider-load-buffer)
|
|
|
|
(spacemacs//cider-eval-in-repl-no-focus (cider-test-run-test)))
|
|
|
|
|
|
|
|
(defun spacemacs/cider-test-run-all-tests ()
|
|
|
|
(interactive)
|
|
|
|
(cider-load-buffer)
|
|
|
|
(spacemacs//cider-eval-in-repl-no-focus (cider-test-run-tests nil)))
|
|
|
|
|
|
|
|
(defun spacemacs/cider-test-rerun-tests ()
|
|
|
|
(interactive)
|
|
|
|
(cider-load-buffer)
|
|
|
|
(spacemacs//cider-eval-in-repl-no-focus (cider-test-rerun-tests)))
|
|
|
|
|
2015-03-24 14:32:33 +00:00
|
|
|
(evilify cider-stacktrace-mode cider-stacktrace-mode-map)
|
|
|
|
|
2015-04-02 18:53:43 +00:00
|
|
|
;; open cider-doc directly and close it with q
|
|
|
|
(setq cider-prompt-for-symbol nil)
|
|
|
|
(evilify cider-docview-mode cider-docview-mode-map
|
2015-04-13 19:29:46 +00:00
|
|
|
(kbd "q") 'cider-popup-buffer-quit)
|
2015-04-02 18:53:43 +00:00
|
|
|
|
2014-12-17 05:58:14 +00:00
|
|
|
(evil-leader/set-key-for-mode 'clojure-mode
|
2015-04-02 17:35:02 +00:00
|
|
|
"mhh" 'cider-doc
|
|
|
|
"mhg" 'cider-grimoire
|
|
|
|
"mhj" 'cider-javadoc
|
2015-02-20 03:31:32 +00:00
|
|
|
|
2015-02-20 02:59:53 +00:00
|
|
|
"meb" 'cider-eval-buffer
|
2015-02-24 02:05:15 +00:00
|
|
|
"mee" 'cider-eval-last-sexp
|
2015-03-21 02:50:05 +00:00
|
|
|
"mef" 'cider-eval-defun-at-point
|
2015-02-20 02:59:53 +00:00
|
|
|
"mer" 'cider-eval-region
|
2015-06-08 04:30:40 +00:00
|
|
|
"mew" 'cider-eval-last-sexp-and-replace
|
2015-02-20 03:31:32 +00:00
|
|
|
|
2015-02-20 02:59:53 +00:00
|
|
|
"mgb" 'cider-jump-back
|
|
|
|
"mge" 'cider-jump-to-compilation-error
|
2015-02-18 16:13:05 +00:00
|
|
|
"mgg" 'cider-jump-to-var
|
2014-12-17 05:58:14 +00:00
|
|
|
"mgr" 'cider-jump-to-resource
|
2015-02-20 03:31:32 +00:00
|
|
|
|
|
|
|
"msb" 'cider-load-buffer
|
2015-03-14 05:46:05 +00:00
|
|
|
"msB" 'spacemacs/cider-send-buffer-in-repl-and-focus
|
2015-05-08 15:50:48 +00:00
|
|
|
"msc" 'cider-connect
|
2015-03-14 05:46:05 +00:00
|
|
|
"mse" 'spacemacs/cider-send-last-sexp-to-repl
|
|
|
|
"msE" 'spacemacs/cider-send-last-sexp-to-repl-focus
|
|
|
|
"msf" 'spacemacs/cider-send-function-to-repl
|
|
|
|
"msF" 'spacemacs/cider-send-function-to-repl-focus
|
2015-02-20 03:31:32 +00:00
|
|
|
"msi" 'cider-jack-in
|
2015-03-14 05:46:05 +00:00
|
|
|
"msn" 'spacemacs/cider-send-ns-form-to-repl
|
2015-03-29 13:48:28 +00:00
|
|
|
"msN" 'spacemacs/cider-send-ns-form-to-repl-focus
|
2015-03-15 01:00:56 +00:00
|
|
|
"msq" 'cider-quit
|
2015-03-14 05:46:05 +00:00
|
|
|
"msr" 'spacemacs/cider-send-region-to-repl
|
|
|
|
"msR" 'spacemacs/cider-send-region-to-repl-focus
|
2015-02-20 03:31:32 +00:00
|
|
|
"mss" 'cider-switch-to-repl-buffer
|
|
|
|
|
2015-05-19 03:03:32 +00:00
|
|
|
"mta" 'spacemacs/cider-test-run-all-tests
|
|
|
|
"mtr" 'spacemacs/cider-test-rerun-tests
|
|
|
|
"mtt" 'spacemacs/cider-test-run-focused-test)
|
2015-03-05 21:56:11 +00:00
|
|
|
(when clojure-enable-fancify-symbols
|
2015-04-29 11:11:22 +00:00
|
|
|
(clojure/fancify-symbols 'cider-repl-mode)))
|
|
|
|
|
2015-05-10 05:32:13 +00:00
|
|
|
(when (configuration-layer/package-usedp 'evil-jumper)
|
|
|
|
(defadvice cider-jump-to-var (before add-evil-jump activate)
|
2015-04-29 11:11:22 +00:00
|
|
|
(evil-set-jump)))))
|
2014-12-11 12:07:49 +00:00
|
|
|
|
2015-04-05 03:25:11 +00:00
|
|
|
(defun clojure/init-cider-eval-sexp-fu ()
|
|
|
|
(eval-after-load 'eval-sexp-fu
|
|
|
|
'(require 'cider-eval-sexp-fu)))
|
|
|
|
|
2014-12-11 12:07:49 +00:00
|
|
|
(defun clojure/init-clj-refactor ()
|
|
|
|
(use-package clj-refactor
|
|
|
|
:defer t
|
2015-02-24 02:50:04 +00:00
|
|
|
:init
|
|
|
|
(add-hook 'clojure-mode-hook 'clj-refactor-mode)
|
2015-02-16 13:13:14 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-02-24 02:50:04 +00:00
|
|
|
(cljr-add-keybindings-with-prefix "C-c C-f")
|
|
|
|
;; not supported for now
|
|
|
|
;; (spacemacs/declare-prefix "mr" "clj-refactor")
|
2015-02-16 13:13:14 +00:00
|
|
|
(evil-leader/set-key-for-mode 'clojure-mode
|
2015-02-24 02:50:04 +00:00
|
|
|
"mrad" 'cljr-add-declaration
|
|
|
|
"mrai" 'cljr-add-import-to-ns
|
|
|
|
"mram" 'cljr-add-missing-libspec
|
|
|
|
"mrap" 'cljr-add-project-dependency
|
|
|
|
"mrar" 'cljr-add-require-to-ns
|
|
|
|
"mrau" 'cljr-add-use-to-ns
|
|
|
|
"mrcc" 'cljr-cycle-coll
|
|
|
|
"mrci" 'cljr-cycle-if
|
|
|
|
"mrcn" 'cljr-clean-ns
|
|
|
|
"mrcp" 'cljr-cycle-privacy
|
|
|
|
"mrdk" 'cljr-destructure-keys
|
|
|
|
"mref" 'cljr-extract-function
|
|
|
|
"mrel" 'cljr-expand-let
|
|
|
|
"mrfu" 'cljr-find-usages
|
|
|
|
"mrhd" 'cljr-hotload-dependency
|
|
|
|
"mril" 'cljr-introduce-let
|
|
|
|
"mrmf" 'cljr-move-form
|
|
|
|
"mrml" 'cljr-move-to-let
|
|
|
|
"mrpc" 'cljr-project-clean
|
|
|
|
"mrpf" 'cljr-promote-function
|
|
|
|
"mrrd" 'cljr-remove-debug-fns
|
|
|
|
"mrrf" 'cljr-rename-file
|
|
|
|
"mrrl" 'cljr-remove-let
|
|
|
|
"mrrr" 'cljr-remove-unused-requires
|
|
|
|
"mrrs" 'cljr-rename-symbol
|
|
|
|
"mrru" 'cljr-replace-use
|
|
|
|
"mrsn" 'cljr-sort-ns
|
|
|
|
"mrsp" 'cljr-sort-project-dependencies
|
|
|
|
"mrsr" 'cljr-stop-referring
|
|
|
|
"mrtf" 'cljr-thread-first-all
|
|
|
|
"mrth" 'cljr-thread
|
|
|
|
"mrtl" 'cljr-thread-last-all
|
|
|
|
"mrua" 'cljr-unwind-all
|
|
|
|
"mruw" 'cljr-unwind))))
|
2015-02-20 04:37:06 +00:00
|
|
|
|
2015-02-20 04:41:20 +00:00
|
|
|
(defun clojure/init-clojure-mode ()
|
|
|
|
(use-package clojure-mode
|
|
|
|
:defer t
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(when clojure-enable-fancify-symbols
|
|
|
|
(clojure/fancify-symbols 'clojure-mode)))))
|
2015-02-20 04:37:06 +00:00
|
|
|
(defun clojure/init-rainbow-delimiters ()
|
2015-04-03 23:13:52 +00:00
|
|
|
(if (configuration-layer/package-usedp 'cider)
|
2015-02-20 05:14:12 +00:00
|
|
|
(add-hook 'cider-mode-hook 'rainbow-delimiters-mode)))
|
2015-02-20 04:37:06 +00:00
|
|
|
|
|
|
|
(defun clojure/init-subword ()
|
|
|
|
(unless (version< emacs-version "24.4")
|
|
|
|
(add-hook 'cider-mode-hook 'subword-mode)))
|
2015-04-03 22:33:37 +00:00
|
|
|
|
2015-04-03 23:13:52 +00:00
|
|
|
(when (configuration-layer/layer-usedp 'auto-completion)
|
2015-04-06 03:13:00 +00:00
|
|
|
(defun clojure/post-init-company ()
|
|
|
|
(push 'company-capf company-backends-cider-mode)
|
2015-04-09 03:57:22 +00:00
|
|
|
(spacemacs|add-company-hook cider-mode)
|
|
|
|
|
2015-04-06 03:13:00 +00:00
|
|
|
(push 'company-capf company-backends-cider-repl-mode)
|
2015-04-09 03:57:22 +00:00
|
|
|
(spacemacs|add-company-hook cider-repl-mode)))
|