2017-08-28 14:41:45 +00:00
|
|
|
;;; packages.el --- Clojure Layer packages File for Spacemacs
|
|
|
|
;;
|
2018-01-04 07:00:25 +00:00
|
|
|
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
2017-08-28 14:41:45 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2015-04-19 03:40:24 +00:00
|
|
|
(setq clojure-packages
|
2018-11-20 19:55:37 +00:00
|
|
|
'(
|
|
|
|
cider
|
2017-05-29 09:35:22 +00:00
|
|
|
cider-eval-sexp-fu
|
2018-10-04 08:58:13 +00:00
|
|
|
(clj-refactor :toggle clojure-enable-clj-refactor)
|
2017-05-29 09:35:22 +00:00
|
|
|
clojure-mode
|
2017-07-02 13:48:06 +00:00
|
|
|
(clojure-snippets :toggle (configuration-layer/layer-used-p 'auto-completion))
|
2017-05-29 09:35:22 +00:00
|
|
|
company
|
|
|
|
eldoc
|
2018-01-04 06:34:23 +00:00
|
|
|
evil-cleverparens
|
2019-01-14 08:19:14 +00:00
|
|
|
flycheck
|
[clojure] Added support for joker linter and having mutliple active linters
The variable clojure-enable-linters can now be set to a list of linters:
'(clj-kondo joker)
or
'(joker squiggly)
or any other combination of the available linters.
In which case, all linters in the list will be active if they are
available to be. In that flycheck is configured so that each linter
in the list has as next-checker the next linter in the list.
The variable can also now be set to:
'joker
If only the newly added joker linter should be used.
This will pull down flycheck-joker and add Joker as a checker for
Clojure modes.
--
Implementation Details
The way it works is that for each Clojure linting mode, clj, cljc,
cljs and edn, a primary linter is chosen based on the order the
user specifies in clojure-enable-linters which support that mode.
It is made the primary linter for flycheck to use by being promoted
to the front of the flycheck-checkers list. All other linters specified
by the user which the mode also supports get added to it as a
next-checker.
Tested with clj-kondo, joker and squiggly. The only issue I saw was that
the way flycheck-clojure works, and the way I currently have setup the
logic for multiple checkers mean that we can't add to a mode multiple
checkers for the same linter. flycheck-clojure has eastwood, kibit and
core.typed. If you have it configured to use eastwood linter, then it
will all work, as eastwood gets added as the next-checker. But if you
have it disabled in flycheck-clojure, there won't be any
flycheck-clojure linters to activate. I'm not sure as of now how to best
support that. Ideally, we would not clubber linters into a single packge
like that, and so the layer would have instead of squiggly: eastwood,
kibit, core.typed. But that's not how flycheck-clojure works. Future
commit might be able to do something smarter about this.
2019-09-02 07:25:45 +00:00
|
|
|
(flycheck-clojure :toggle (memq 'squiggly (if (listp clojure-enable-linters)
|
|
|
|
clojure-enable-linters
|
|
|
|
(list clojure-enable-linters))))
|
|
|
|
(flycheck-clj-kondo :toggle (memq 'clj-kondo (if (listp clojure-enable-linters)
|
|
|
|
clojure-enable-linters
|
|
|
|
(list clojure-enable-linters))))
|
|
|
|
(flycheck-joker :toggle (memq 'joker (if (listp clojure-enable-linters)
|
|
|
|
clojure-enable-linters
|
|
|
|
(list clojure-enable-linters))))
|
2017-05-29 09:35:22 +00:00
|
|
|
ggtags
|
2017-08-26 21:18:09 +00:00
|
|
|
counsel-gtags
|
2017-05-29 09:35:22 +00:00
|
|
|
helm-gtags
|
|
|
|
org
|
|
|
|
parinfer
|
|
|
|
popwin
|
2018-08-21 08:19:36 +00:00
|
|
|
(sayid :toggle clojure-enable-sayid)
|
2017-05-29 09:35:22 +00:00
|
|
|
smartparens
|
2018-11-20 19:55:37 +00:00
|
|
|
subword
|
|
|
|
))
|
2017-05-29 09:35:22 +00:00
|
|
|
|
2014-12-11 12:07:49 +00:00
|
|
|
(defun clojure/init-cider ()
|
|
|
|
(use-package cider
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2014-12-11 12:07:49 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2016-01-26 16:31:15 +00:00
|
|
|
(spacemacs/register-repl 'cider 'cider-jack-in "cider")
|
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
|
2017-02-06 14:17:57 +00:00
|
|
|
cider-repl-use-clojure-font-lock t
|
|
|
|
cider-repl-history-file (concat spacemacs-cache-directory "cider-repl-history"))
|
2016-08-13 13:43:37 +00:00
|
|
|
(add-hook 'clojure-mode-hook 'cider-mode)
|
2019-02-19 19:07:35 +00:00
|
|
|
|
2016-09-04 16:24:43 +00:00
|
|
|
(dolist (x '(spacemacs-jump-handlers-clojure-mode
|
|
|
|
spacemacs-jump-handlers-clojurec-mode
|
|
|
|
spacemacs-jump-handlers-clojurescript-mode
|
|
|
|
spacemacs-jump-handlers-clojurex-mode
|
|
|
|
spacemacs-jump-handlers-cider-repl-mode))
|
2019-02-19 19:07:35 +00:00
|
|
|
(add-to-list x '(spacemacs/clj-find-var :async t)))
|
2017-05-30 09:58:17 +00:00
|
|
|
|
|
|
|
;; TODO: having this work for cider-macroexpansion-mode would be nice,
|
|
|
|
;; but the problem is that it uses clojure-mode as its major-mode
|
|
|
|
(let ((cider--key-binding-prefixes
|
2020-01-27 16:35:57 +00:00
|
|
|
'(("m=" . "format")
|
|
|
|
("m=e" . "edn")
|
|
|
|
("md" . "debug")
|
2017-05-30 09:58:17 +00:00
|
|
|
("me" . "evaluation")
|
|
|
|
("mg" . "goto")
|
|
|
|
("mh" . "documentation")
|
2020-01-27 16:35:57 +00:00
|
|
|
("mm" . "manage repls")
|
|
|
|
("mml" . "link session")
|
|
|
|
("mmS" . "sibling sessions")
|
|
|
|
("mmq" . "quit/restart")
|
2018-02-24 15:40:06 +00:00
|
|
|
("mp" . "profile")
|
2020-01-27 16:35:57 +00:00
|
|
|
("ms" . "send to repl")
|
|
|
|
("msc" . "connect external repl")
|
2019-07-11 14:01:40 +00:00
|
|
|
("msj" . "jack-in")
|
2020-01-27 16:35:57 +00:00
|
|
|
("msq" . "quit/restart repl")
|
2017-05-30 09:58:17 +00:00
|
|
|
("mt" . "test")
|
|
|
|
("mT" . "toggle")
|
2018-02-19 09:00:21 +00:00
|
|
|
)))
|
2018-11-01 12:10:13 +00:00
|
|
|
(spacemacs|forall-clojure-modes m
|
2017-05-30 09:58:17 +00:00
|
|
|
(mapc (lambda (x) (spacemacs/declare-prefix-for-mode
|
|
|
|
m (car x) (cdr x)))
|
|
|
|
cider--key-binding-prefixes)
|
|
|
|
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode m
|
2020-01-27 16:35:57 +00:00
|
|
|
|
|
|
|
;; shortcuts
|
|
|
|
"'" 'sesman-start
|
|
|
|
|
|
|
|
;; help / documentation
|
2017-05-30 09:58:17 +00:00
|
|
|
"ha" 'cider-apropos
|
2019-01-13 22:41:51 +00:00
|
|
|
"hc" 'cider-cheatsheet
|
2019-08-26 19:28:54 +00:00
|
|
|
"hd" 'cider-clojuredocs
|
2018-02-24 15:40:06 +00:00
|
|
|
"hh" 'cider-doc
|
2017-05-30 09:58:17 +00:00
|
|
|
"hj" 'cider-javadoc
|
|
|
|
"hn" 'cider-browse-ns
|
2018-06-13 16:00:17 +00:00
|
|
|
"hN" 'cider-browse-ns-all
|
2017-05-30 09:58:17 +00:00
|
|
|
|
2020-01-27 16:35:57 +00:00
|
|
|
;; evaluate in source code buffer
|
2017-05-30 09:58:17 +00:00
|
|
|
"e;" 'cider-eval-defun-to-comment
|
|
|
|
"eb" 'cider-eval-buffer
|
|
|
|
"ee" 'cider-eval-last-sexp
|
|
|
|
"ef" 'cider-eval-defun-at-point
|
2019-06-12 14:55:01 +00:00
|
|
|
"ei" 'cider-interrupt
|
2017-05-30 09:58:17 +00:00
|
|
|
"em" 'cider-macroexpand-1
|
|
|
|
"eM" 'cider-macroexpand-all
|
2020-01-27 16:35:57 +00:00
|
|
|
"en" 'cider-ns-refresh
|
|
|
|
"eN" 'cider-ns-reload ;; SPC u for cider-ns-reload-all
|
|
|
|
"ep" 'cider-pprint-eval-defun-at-point
|
2017-06-20 21:53:01 +00:00
|
|
|
"eP" 'cider-pprint-eval-last-sexp
|
2018-02-24 15:40:06 +00:00
|
|
|
"er" 'cider-eval-region
|
2019-04-19 19:59:51 +00:00
|
|
|
"eu" 'cider-undef
|
2019-07-03 22:06:11 +00:00
|
|
|
"ev" 'cider-eval-sexp-at-point
|
2020-01-27 16:35:57 +00:00
|
|
|
"eV" 'cider-eval-sexp-up-to-point
|
2017-05-30 09:58:17 +00:00
|
|
|
"ew" 'cider-eval-last-sexp-and-replace
|
|
|
|
|
2020-01-27 16:35:57 +00:00
|
|
|
;; format code style
|
|
|
|
"==" 'cider-format-buffer
|
|
|
|
"=eb" 'cider-format-edn-buffer
|
|
|
|
"=ee" 'cider-format-edn-last-sexp
|
|
|
|
"=er" 'cider-format-edn-region
|
|
|
|
"=f" 'cider-format-defun
|
|
|
|
"=r" 'cider-format-region
|
2017-05-30 09:58:17 +00:00
|
|
|
|
2020-01-27 16:35:57 +00:00
|
|
|
;; goto
|
2017-05-30 09:58:17 +00:00
|
|
|
"gb" 'cider-pop-back
|
|
|
|
"gc" 'cider-classpath
|
2019-07-12 12:38:34 +00:00
|
|
|
"gg" 'spacemacs/clj-find-var
|
2017-05-30 09:58:17 +00:00
|
|
|
"ge" 'cider-jump-to-compilation-error
|
2018-06-13 16:00:17 +00:00
|
|
|
"gn" 'cider-find-ns
|
2018-02-24 15:40:06 +00:00
|
|
|
"gr" 'cider-find-resource
|
2018-02-19 09:00:21 +00:00
|
|
|
"gs" 'cider-browse-spec
|
|
|
|
"gS" 'cider-browse-spec-all
|
2017-05-30 09:58:17 +00:00
|
|
|
|
2020-01-27 16:35:57 +00:00
|
|
|
;; manage cider connections / sesman
|
|
|
|
"mb" 'sesman-browser
|
|
|
|
"mi" 'sesman-info
|
|
|
|
"mg" 'sesman-goto
|
|
|
|
"mlb" 'sesman-link-with-buffer
|
|
|
|
"mld" 'sesman-link-with-directory
|
|
|
|
"mlu" 'sesman-unlink
|
|
|
|
"mqq" 'sesman-quit
|
|
|
|
"mqr" 'sesman-restart
|
|
|
|
"mlp" 'sesman-link-with-project
|
|
|
|
"mSj" 'cider-connect-sibling-clj
|
|
|
|
"mSs" 'cider-connect-sibling-cljs
|
|
|
|
"ms" 'sesman-start
|
|
|
|
|
|
|
|
;; send code - spacemacs convention
|
|
|
|
"sa" (if (eq m 'cider-repl-mode)
|
|
|
|
'cider-switch-to-last-clojure-buffer
|
|
|
|
'cider-switch-to-repl-buffer)
|
2020-01-25 15:17:08 +00:00
|
|
|
"sb" 'cider-load-buffer
|
|
|
|
"sB" 'spacemacs/cider-send-buffer-in-repl-and-focus
|
2020-01-27 16:35:57 +00:00
|
|
|
"scj" 'cider-connect-clj
|
|
|
|
"scm" 'cider-connect-clj&cljs
|
|
|
|
"scs" 'cider-connect-cljs
|
2020-01-25 15:17:08 +00:00
|
|
|
"se" 'spacemacs/cider-send-last-sexp-to-repl
|
|
|
|
"sE" 'spacemacs/cider-send-last-sexp-to-repl-focus
|
|
|
|
"sf" 'spacemacs/cider-send-function-to-repl
|
|
|
|
"sF" 'spacemacs/cider-send-function-to-repl-focus
|
2020-01-27 16:35:57 +00:00
|
|
|
"si" 'sesman-start
|
|
|
|
"sjj" 'cider-jack-in-clj
|
|
|
|
"sjm" 'cider-jack-in-clj&cljs
|
2019-07-11 14:01:40 +00:00
|
|
|
"sjs" 'cider-jack-in-cljs
|
2020-01-27 16:35:57 +00:00
|
|
|
"sl" 'cider-repl-clear-buffer
|
|
|
|
"sL" 'cider-find-and-clear-repl-output
|
2020-01-25 15:17:08 +00:00
|
|
|
"sn" 'spacemacs/cider-send-ns-form-to-repl
|
|
|
|
"sN" 'spacemacs/cider-send-ns-form-to-repl-focus
|
2017-05-30 09:58:17 +00:00
|
|
|
"so" 'cider-repl-switch-to-other
|
2020-01-27 16:35:57 +00:00
|
|
|
"sqq" 'cider-quit
|
|
|
|
"sqr" 'cider-restart
|
|
|
|
"sqn" 'cider-ns-reload
|
|
|
|
"sqN" 'cider-ns-reload-all
|
2020-01-25 15:17:08 +00:00
|
|
|
"sr" 'spacemacs/cider-send-region-to-repl
|
|
|
|
"sR" 'spacemacs/cider-send-region-to-repl-focus
|
|
|
|
"su" 'cider-repl-require-repl-utils
|
2017-05-30 09:58:17 +00:00
|
|
|
|
2020-01-27 16:35:57 +00:00
|
|
|
;; toggle options
|
2017-05-30 09:58:17 +00:00
|
|
|
"Te" 'cider-enlighten-mode
|
|
|
|
"Tf" 'spacemacs/cider-toggle-repl-font-locking
|
|
|
|
"Tp" 'spacemacs/cider-toggle-repl-pretty-printing
|
|
|
|
"Tt" 'cider-auto-test-mode
|
|
|
|
|
2020-01-27 16:35:57 +00:00
|
|
|
;; cider-tests
|
2017-05-30 09:58:17 +00:00
|
|
|
"ta" 'spacemacs/cider-test-run-all-tests
|
|
|
|
"tb" 'cider-test-show-report
|
|
|
|
"tl" 'spacemacs/cider-test-run-loaded-tests
|
|
|
|
"tn" 'spacemacs/cider-test-run-ns-tests
|
2018-02-24 15:40:06 +00:00
|
|
|
"tp" 'spacemacs/cider-test-run-project-tests
|
2017-05-30 09:58:17 +00:00
|
|
|
"tr" 'spacemacs/cider-test-rerun-failed-tests
|
|
|
|
"tt" 'spacemacs/cider-test-run-focused-test
|
|
|
|
|
2020-01-27 16:35:57 +00:00
|
|
|
;; cider-debug
|
2017-05-30 09:58:17 +00:00
|
|
|
"db" 'cider-debug-defun-at-point
|
|
|
|
"de" 'spacemacs/cider-display-error-buffer
|
|
|
|
"dv" 'cider-inspect
|
|
|
|
|
2018-02-19 09:00:21 +00:00
|
|
|
;; profile
|
2018-02-24 15:40:06 +00:00
|
|
|
"p+" 'cider-profile-samples
|
2018-02-19 09:00:21 +00:00
|
|
|
"pc" 'cider-profile-clear
|
|
|
|
"pn" 'cider-profile-ns-toggle
|
2018-02-24 15:40:06 +00:00
|
|
|
"ps" 'cider-profile-var-summary
|
|
|
|
"pS" 'cider-profile-summary
|
|
|
|
"pt" 'cider-profile-toggle
|
2018-02-19 09:00:21 +00:00
|
|
|
"pv" 'cider-profile-var-profiled-p
|
2018-02-24 15:40:06 +00:00
|
|
|
)))
|
2017-05-30 09:58:17 +00:00
|
|
|
|
|
|
|
;; cider-repl-mode only
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'cider-repl-mode
|
|
|
|
"," 'cider-repl-handle-shortcut)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'cider-clojure-interaction-mode
|
|
|
|
"ep" 'cider-eval-print-last-sexp))
|
2014-12-11 12:07:49 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-02-24 01:52:49 +00:00
|
|
|
;; add support for golden-ratio
|
2015-09-29 05:07:57 +00:00
|
|
|
(with-eval-after-load 'golden-ratio
|
2018-06-01 06:59:57 +00:00
|
|
|
(add-to-list 'golden-ratio-extra-commands 'cider-popup-buffer-quit-function))
|
2015-02-24 01:52:49 +00:00
|
|
|
;; add support for evil
|
2015-12-15 21:36:18 +00:00
|
|
|
(evil-set-initial-state 'cider-stacktrace-mode 'motion)
|
|
|
|
(evil-set-initial-state 'cider-popup-buffer-mode 'motion)
|
2015-08-18 12:39:25 +00:00
|
|
|
(add-hook 'cider--debug-mode-hook 'spacemacs/cider-debug-setup)
|
|
|
|
|
2015-11-21 10:07:14 +00:00
|
|
|
(evilified-state-evilify cider-stacktrace-mode cider-stacktrace-mode-map
|
|
|
|
(kbd "C-j") 'cider-stacktrace-next-cause
|
|
|
|
(kbd "C-k") 'cider-stacktrace-previous-cause
|
|
|
|
(kbd "TAB") 'cider-stacktrace-cycle-current-cause
|
|
|
|
(kbd "0") 'cider-stacktrace-cycle-all-causes
|
|
|
|
(kbd "1") 'cider-stacktrace-cycle-cause-1
|
|
|
|
(kbd "2") 'cider-stacktrace-cycle-cause-2
|
|
|
|
(kbd "3") 'cider-stacktrace-cycle-cause-3
|
|
|
|
(kbd "4") 'cider-stacktrace-cycle-cause-4
|
|
|
|
(kbd "5") 'cider-stacktrace-cycle-cause-5
|
|
|
|
(kbd "a") 'cider-stacktrace-toggle-all
|
|
|
|
(kbd "c") 'cider-stacktrace-toggle-clj
|
|
|
|
(kbd "d") 'cider-stacktrace-toggle-duplicates
|
|
|
|
(kbd "J") 'cider-stacktrace-toggle-java
|
|
|
|
(kbd "r") 'cider-stacktrace-toggle-repl
|
|
|
|
(kbd "T") 'cider-stacktrace-toggle-tooling)
|
2015-03-24 14:32:33 +00:00
|
|
|
|
2015-04-02 18:53:43 +00:00
|
|
|
;; open cider-doc directly and close it with q
|
|
|
|
(setq cider-prompt-for-symbol nil)
|
2015-08-14 10:11:29 +00:00
|
|
|
|
2015-11-21 10:07:14 +00:00
|
|
|
(evilified-state-evilify cider-docview-mode cider-docview-mode-map
|
|
|
|
(kbd "q") 'cider-popup-buffer-quit)
|
|
|
|
|
|
|
|
(evilified-state-evilify cider-inspector-mode cider-inspector-mode-map
|
|
|
|
(kbd "L") 'cider-inspector-pop
|
|
|
|
(kbd "n") 'cider-inspector-next-page
|
2017-08-28 14:57:38 +00:00
|
|
|
(kbd "N") 'cider-inspector-prev-page
|
|
|
|
(kbd "p") 'cider-inspector-prev-page
|
2015-11-21 10:07:14 +00:00
|
|
|
(kbd "r") 'cider-inspector-refresh)
|
|
|
|
|
|
|
|
(evilified-state-evilify cider-test-report-mode cider-test-report-mode-map
|
|
|
|
(kbd "C-j") 'cider-test-next-result
|
|
|
|
(kbd "C-k") 'cider-test-previous-result
|
|
|
|
(kbd "RET") 'cider-test-jump
|
|
|
|
(kbd "d") 'cider-test-ediff
|
|
|
|
(kbd "e") 'cider-test-stacktrace
|
|
|
|
(kbd "q") 'cider-popup-buffer-quit
|
|
|
|
(kbd "r") 'cider-test-rerun-tests
|
|
|
|
(kbd "t") 'cider-test-run-test
|
2016-02-15 11:10:50 +00:00
|
|
|
(kbd "T") 'cider-test-run-ns-tests)
|
2015-08-14 10:11:29 +00:00
|
|
|
|
2015-08-14 09:58:45 +00:00
|
|
|
(evil-define-key 'normal cider-repl-mode-map
|
2016-11-18 15:00:47 +00:00
|
|
|
(kbd "C-j") 'cider-repl-next-input
|
2018-10-12 22:41:16 +00:00
|
|
|
(kbd "C-k") 'cider-repl-previous-input
|
|
|
|
(kbd "RET") 'cider-repl-return)
|
2018-05-23 20:27:20 +00:00
|
|
|
|
2019-09-17 05:54:14 +00:00
|
|
|
(if (package-installed-p 'company)
|
|
|
|
(evil-define-key 'insert cider-repl-mode-map
|
|
|
|
(kbd "C-j") 'spacemacs//clj-repl-wrap-c-j
|
|
|
|
(kbd "C-k") 'spacemacs//clj-repl-wrap-c-k)
|
|
|
|
(evil-define-key 'insert cider-repl-mode-map
|
|
|
|
(kbd "C-j") 'cider-repl-next-input
|
|
|
|
(kbd "C-k") 'cider-repl-previous-input))
|
2015-08-14 09:58:45 +00:00
|
|
|
|
2019-09-24 16:45:07 +00:00
|
|
|
(evil-define-key 'insert cider-repl-mode-map
|
|
|
|
(kbd "<C-return>") 'cider-repl-newline-and-indent)
|
|
|
|
|
2015-03-05 21:56:11 +00:00
|
|
|
(when clojure-enable-fancify-symbols
|
2016-03-07 23:14:21 +00:00
|
|
|
(clojure/fancify-symbols 'cider-repl-mode)
|
|
|
|
(clojure/fancify-symbols 'cider-clojure-interaction-mode)))
|
2015-04-29 11:11:22 +00:00
|
|
|
|
2019-08-25 15:27:55 +00:00
|
|
|
(defadvice cider-find-var (before add-evil-jump activate)
|
2016-02-15 19:15:29 +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 ()
|
2015-09-29 05:07:57 +00:00
|
|
|
(with-eval-after-load 'eval-sexp-fu
|
|
|
|
(require 'cider-eval-sexp-fu)))
|
2015-04-05 03:25:11 +00:00
|
|
|
|
2014-12-11 12:07:49 +00:00
|
|
|
(defun clojure/init-clj-refactor ()
|
2015-08-14 09:57:24 +00:00
|
|
|
(use-package clj-refactor
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-08-14 09:57:24 +00:00
|
|
|
:init
|
|
|
|
(add-hook 'clojure-mode-hook 'clj-refactor-mode)
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(cljr-add-keybindings-with-prefix "C-c C-f")
|
2017-05-30 09:58:17 +00:00
|
|
|
;; Usually we do not set keybindings in :config, however this must be done
|
|
|
|
;; here because it reads the variable `cljr--all-helpers'. Since
|
|
|
|
;; `clj-refactor-mode' is added to the hook, this should trigger when a
|
|
|
|
;; clojure buffer is opened anyway, so there's no "keybinding delay".
|
2018-11-01 12:10:13 +00:00
|
|
|
(spacemacs|forall-clojure-modes m
|
|
|
|
(dolist (r cljr--all-helpers)
|
|
|
|
(let* ((binding (car r))
|
|
|
|
(func (cadr r)))
|
|
|
|
(when (not (string-prefix-p "hydra" (symbol-name func)))
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode m
|
|
|
|
(concat "r" binding) func))))))))
|
2015-02-20 04:37:06 +00:00
|
|
|
|
2017-12-18 00:51:13 +00:00
|
|
|
|
2015-02-20 04:41:20 +00:00
|
|
|
(defun clojure/init-clojure-mode ()
|
|
|
|
(use-package clojure-mode
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-07-07 14:15:46 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.boot\\'" . clojure-mode))
|
2016-05-05 21:38:13 +00:00
|
|
|
;; This regexp matches shebang expressions like `#!/usr/bin/env boot'
|
2017-05-30 09:58:17 +00:00
|
|
|
(add-to-list 'magic-mode-alist '("#!.*boot\\s-*$" . clojure-mode))
|
2018-11-01 12:10:13 +00:00
|
|
|
;; Define all the prefixes here, although most of them apply only to bindings in clj-refactor
|
|
|
|
(let ((clj-refactor--key-binding-prefixes
|
|
|
|
'(("mr" . "refactor")
|
|
|
|
("mra" . "add")
|
|
|
|
("mrc" . "cycle/clean/convert")
|
|
|
|
("mrd" . "destructure")
|
|
|
|
("mre" . "extract/expand")
|
|
|
|
("mrf" . "find/function")
|
|
|
|
("mrh" . "hotload")
|
|
|
|
("mri" . "introduce/inline")
|
|
|
|
("mrm" . "move")
|
|
|
|
("mrp" . "project/promote")
|
|
|
|
("mrr" . "remove/rename/replace")
|
|
|
|
("mrs" . "show/sort/stop")
|
|
|
|
("mrt" . "thread")
|
|
|
|
("mru" . "unwind/update"))))
|
|
|
|
(spacemacs|forall-clojure-modes m
|
|
|
|
(mapc (lambda (x) (spacemacs/declare-prefix-for-mode
|
|
|
|
m (car x) (cdr x)))
|
|
|
|
clj-refactor--key-binding-prefixes)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode m
|
2020-01-27 16:35:57 +00:00
|
|
|
"=l" 'clojure-align
|
2018-11-01 12:10:13 +00:00
|
|
|
"rci" 'clojure-cycle-if
|
|
|
|
"rcp" 'clojure-cycle-privacy
|
|
|
|
"rc#" 'clojure-convert-collection-to-set
|
|
|
|
"rc'" 'clojure-convert-collection-to-quoted-list
|
|
|
|
"rc(" 'clojure-convert-collection-to-list
|
|
|
|
"rc[" 'clojure-convert-collection-to-vector
|
|
|
|
"rc{" 'clojure-convert-collection-to-map
|
|
|
|
"rc:" 'clojure-toggle-keyword-string
|
|
|
|
"rtf" 'clojure-thread-first-all
|
|
|
|
"rth" 'clojure-thread
|
|
|
|
"rtl" 'clojure-thread-last-all
|
|
|
|
"rua" 'clojure-unwind-all
|
|
|
|
"ruw" 'clojure-unwind)
|
|
|
|
(unless clojure-enable-clj-refactor
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode m
|
|
|
|
"r?" 'spacemacs/clj-describe-missing-refactorings)))))
|
2017-05-30 09:58:17 +00:00
|
|
|
:config
|
|
|
|
(when clojure-enable-fancify-symbols
|
2018-11-01 12:10:13 +00:00
|
|
|
(spacemacs|forall-clojure-modes m
|
2017-05-30 09:58:17 +00:00
|
|
|
(clojure/fancify-symbols m)))))
|
2015-07-26 05:18:16 +00:00
|
|
|
|
2016-04-11 18:30:47 +00:00
|
|
|
(defun clojure/post-init-eldoc ()
|
|
|
|
(add-hook 'cider-mode-hook 'eldoc-mode)
|
2016-03-07 23:14:21 +00:00
|
|
|
(add-hook 'cider-repl-mode-hook 'eldoc-mode)
|
|
|
|
(add-hook 'cider-clojure-interaction-mode-hook 'eldoc-mode))
|
2016-04-11 18:30:47 +00:00
|
|
|
|
2018-01-04 06:34:23 +00:00
|
|
|
(defun clojure/pre-init-evil-cleverparens ()
|
|
|
|
(spacemacs|use-package-add-hook evil-cleverparens
|
|
|
|
:pre-init
|
2018-11-01 12:10:13 +00:00
|
|
|
(spacemacs|forall-clojure-modes m
|
2018-01-22 11:40:06 +00:00
|
|
|
(add-to-list 'evil-lisp-safe-structural-editing-modes m))))
|
2018-01-04 06:34:23 +00:00
|
|
|
|
2015-07-26 05:18:16 +00:00
|
|
|
(defun clojure/pre-init-popwin ()
|
|
|
|
(spacemacs|use-package-add-hook popwin
|
|
|
|
:post-config
|
|
|
|
(push '("*cider-error*" :dedicated t :position bottom :stick t :noselect nil :height 0.4)
|
2015-07-26 05:22:13 +00:00
|
|
|
popwin:special-display-config)
|
|
|
|
(push '("*cider-doc*" :dedicated t :position bottom :stick t :noselect nil :height 0.4)
|
2015-07-26 05:18:16 +00:00
|
|
|
popwin:special-display-config)))
|
|
|
|
|
2018-03-04 04:37:53 +00:00
|
|
|
(defun clojure/post-init-smartparens ()
|
|
|
|
(add-hook 'cider-repl-mode-hook
|
|
|
|
(if dotspacemacs-smartparens-strict-mode
|
|
|
|
#'smartparens-strict-mode
|
|
|
|
#'smartparens-mode))
|
|
|
|
(with-eval-after-load 'smartparens
|
|
|
|
(sp-local-pair 'clojure-mode "`" nil :actions nil)))
|
2016-06-11 16:41:20 +00:00
|
|
|
|
2015-08-09 03:35:16 +00:00
|
|
|
(defun clojure/post-init-subword ()
|
2016-03-15 03:17:09 +00:00
|
|
|
(add-hook 'cider-mode-hook 'subword-mode))
|
2015-04-03 22:33:37 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun clojure/post-init-company ()
|
2017-01-02 05:39:04 +00:00
|
|
|
(spacemacs|add-company-backends
|
|
|
|
:backends company-capf
|
|
|
|
:modes
|
2017-01-06 21:21:45 +00:00
|
|
|
cider-mode
|
|
|
|
cider-repl-mode))
|
2016-02-28 08:28:12 +00:00
|
|
|
|
2016-04-05 04:08:34 +00:00
|
|
|
(defun clojure/post-init-ggtags ()
|
2016-08-15 19:24:44 +00:00
|
|
|
(add-hook 'clojure-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
|
2016-04-05 04:08:34 +00:00
|
|
|
|
2017-08-26 21:18:09 +00:00
|
|
|
(defun clojure/post-init-counsel-gtags ()
|
|
|
|
(spacemacs/counsel-gtags-define-keys-for-mode 'clojure-mode))
|
|
|
|
|
2016-04-05 04:08:34 +00:00
|
|
|
(defun clojure/post-init-helm-gtags ()
|
|
|
|
(spacemacs/helm-gtags-define-keys-for-mode 'clojure-mode))
|
|
|
|
|
2016-02-28 08:28:12 +00:00
|
|
|
(defun clojure/init-clojure-snippets ()
|
|
|
|
(use-package clojure-snippets
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t))
|
2016-10-04 21:17:13 +00:00
|
|
|
|
|
|
|
(defun clojure/pre-init-org ()
|
|
|
|
(spacemacs|use-package-add-hook org
|
|
|
|
:post-config (add-to-list 'org-babel-load-languages '(clojure . t))
|
|
|
|
(setq org-babel-clojure-backend 'cider)))
|
2017-01-18 11:27:08 +00:00
|
|
|
|
|
|
|
(defun clojure/init-sayid ()
|
|
|
|
(use-package sayid
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2017-01-18 11:27:08 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(setq sayid--key-binding-prefixes
|
|
|
|
'(("mdt" . "trace")))
|
2018-11-01 12:10:13 +00:00
|
|
|
(spacemacs|forall-clojure-modes m
|
|
|
|
(mapc (lambda (x) (spacemacs/declare-prefix-for-mode m
|
|
|
|
(car x) (cdr x)))
|
2017-01-18 11:27:08 +00:00
|
|
|
sayid--key-binding-prefixes)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode m
|
|
|
|
;;These keybindings mostly preserved from the default sayid bindings
|
|
|
|
"d!" 'sayid-load-enable-clear
|
2018-02-24 15:40:06 +00:00
|
|
|
"dE" 'sayid-eval-last-sexp ;in default sayid bindings this is lowercase e, but that was already used in clojure mode
|
2017-01-18 11:27:08 +00:00
|
|
|
"dc" 'sayid-clear-log
|
2018-02-24 15:40:06 +00:00
|
|
|
"df" 'sayid-query-form-at-point
|
|
|
|
"dh" 'sayid-show-help
|
2017-01-18 11:27:08 +00:00
|
|
|
"ds" 'sayid-show-traced
|
|
|
|
"dS" 'sayid-show-traced-ns
|
|
|
|
"dtb" 'sayid-trace-ns-in-file
|
|
|
|
"dtd" 'sayid-trace-fn-disable
|
|
|
|
"dtD" 'sayid-trace-disable-all
|
2018-02-24 15:40:06 +00:00
|
|
|
"dte" 'sayid-trace-fn-enable
|
|
|
|
"dtE" 'sayid-trace-enable-all
|
|
|
|
"dtK" 'sayid-kill-all-traces
|
2017-01-18 11:27:08 +00:00
|
|
|
"dtn" 'sayid-inner-trace-fn
|
|
|
|
"dto" 'sayid-outer-trace-fn
|
2018-02-24 15:40:06 +00:00
|
|
|
"dtp" 'sayid-trace-ns-by-pattern
|
2017-01-18 11:27:08 +00:00
|
|
|
"dtr" 'sayid-remove-trace-fn
|
2018-02-24 15:40:06 +00:00
|
|
|
"dty" 'sayid-trace-all-ns-in-dir
|
|
|
|
"dV" 'sayid-set-view
|
|
|
|
"dw" 'sayid-get-workspace
|
|
|
|
"dx" 'sayid-reset-workspace
|
|
|
|
))
|
2017-01-18 11:27:08 +00:00
|
|
|
|
|
|
|
(evilified-state-evilify sayid-mode sayid-mode-map
|
|
|
|
(kbd "H") 'sayid-buf-show-help
|
|
|
|
(kbd "n") 'sayid-buffer-nav-to-next
|
|
|
|
(kbd "N") 'sayid-buffer-nav-to-prev
|
|
|
|
(kbd "C-s v") 'sayid-toggle-view
|
|
|
|
(kbd "C-s V") 'sayid-set-view
|
|
|
|
(kbd "L") 'sayid-buf-back
|
2017-05-29 09:35:22 +00:00
|
|
|
(kbd "e") 'sayid-gen-instance-expr) ;Originally this was bound to 'g', but I feel this is still mnemonic and doesn't overlap with evil
|
|
|
|
|
2017-01-18 11:27:08 +00:00
|
|
|
(evilified-state-evilify sayid-pprint-mode sayid-pprint-mode-map
|
|
|
|
(kbd "h") 'sayid-pprint-buf-show-help
|
|
|
|
(kbd "n") 'sayid-pprint-buf-next
|
|
|
|
(kbd "N") 'sayid-pprint-buf-prev
|
|
|
|
(kbd "l") 'sayid-pprint-buf-exit)
|
|
|
|
|
|
|
|
(evilified-state-evilify sayid-traced-mode sayid-traced-mode-map
|
|
|
|
(kbd "l") 'sayid-show-traced
|
|
|
|
(kbd "h") 'sayid-traced-buf-show-help))))
|
2017-05-29 09:35:22 +00:00
|
|
|
|
|
|
|
(defun clojure/post-init-parinfer ()
|
2019-04-07 23:41:33 +00:00
|
|
|
(add-hook 'clojure-mode-hook 'parinfer-mode))
|
2019-01-14 08:19:14 +00:00
|
|
|
|
|
|
|
(defun clojure/post-init-flycheck ()
|
[clojure] Added support for joker linter and having mutliple active linters
The variable clojure-enable-linters can now be set to a list of linters:
'(clj-kondo joker)
or
'(joker squiggly)
or any other combination of the available linters.
In which case, all linters in the list will be active if they are
available to be. In that flycheck is configured so that each linter
in the list has as next-checker the next linter in the list.
The variable can also now be set to:
'joker
If only the newly added joker linter should be used.
This will pull down flycheck-joker and add Joker as a checker for
Clojure modes.
--
Implementation Details
The way it works is that for each Clojure linting mode, clj, cljc,
cljs and edn, a primary linter is chosen based on the order the
user specifies in clojure-enable-linters which support that mode.
It is made the primary linter for flycheck to use by being promoted
to the front of the flycheck-checkers list. All other linters specified
by the user which the mode also supports get added to it as a
next-checker.
Tested with clj-kondo, joker and squiggly. The only issue I saw was that
the way flycheck-clojure works, and the way I currently have setup the
logic for multiple checkers mean that we can't add to a mode multiple
checkers for the same linter. flycheck-clojure has eastwood, kibit and
core.typed. If you have it configured to use eastwood linter, then it
will all work, as eastwood gets added as the next-checker. But if you
have it disabled in flycheck-clojure, there won't be any
flycheck-clojure linters to activate. I'm not sure as of now how to best
support that. Ideally, we would not clubber linters into a single packge
like that, and so the layer would have instead of squiggly: eastwood,
kibit, core.typed. But that's not how flycheck-clojure works. Future
commit might be able to do something smarter about this.
2019-09-02 07:25:45 +00:00
|
|
|
;; When user has chosen to use multiple linters.
|
|
|
|
(when (> (safe-length clojure-enable-linters) 1)
|
|
|
|
;; If adding a linter, you must add to checkers-per-mode for each mode
|
|
|
|
;; it can support the mapping from the linter name in clojure-enable-linters
|
|
|
|
;; to the flycheck checker to use to add to flycheck.
|
|
|
|
(let* ((checkers-per-mode '((clj . ((clj-kondo . clj-kondo-clj)
|
|
|
|
(joker . clojure-joker)
|
|
|
|
(squiggly . clojure-cider-eastwood)))
|
|
|
|
(cljc . ((clj-kondo . clj-kondo-cljc)
|
|
|
|
(joker . clojure-joker)))
|
|
|
|
(cljs . ((clj-kondo . clj-kondo-cljs)
|
|
|
|
(joker . clojurescript-joker)))
|
|
|
|
(edn . ((clj-kondo . clj-kondo-edn)
|
|
|
|
(joker . edn-joker))))))
|
|
|
|
;; For each checker mode
|
|
|
|
(dolist (mode-checkers checkers-per-mode)
|
|
|
|
;; We find the first checker in order from the user configured linters which
|
|
|
|
;; the mode supports and make it the primary-linter. All other linters after that
|
|
|
|
;; the mode support is made a next-linter. Finally, we extract the checkers of the
|
|
|
|
;; primary linter and the next linters.
|
|
|
|
(let* ((checkers (cdr mode-checkers))
|
|
|
|
(primary-linter (seq-find (lambda (l)
|
|
|
|
(assq l checkers))
|
|
|
|
clojure-enable-linters))
|
|
|
|
(primary-checker (cdr (assq primary-linter checkers)))
|
|
|
|
(next-linters (seq-filter (lambda (l)
|
|
|
|
(and (not (eq l primary-linter))
|
|
|
|
(assq l checkers)))
|
|
|
|
clojure-enable-linters))
|
|
|
|
(next-checkers (mapcar (lambda (l)
|
|
|
|
(cdr (assq l checkers)))
|
|
|
|
next-linters)))
|
|
|
|
;; Move primary checker to the front of flycheck lists of checkers so that
|
|
|
|
;; it is used as the primary checker, because flycheck picks the first one
|
|
|
|
;; it finds.
|
|
|
|
(delq primary-checker flycheck-checkers)
|
|
|
|
(push primary-checker flycheck-checkers)
|
|
|
|
;; For every checker, set their next checkers, starting with the primary
|
|
|
|
;; checker which has all others has a next-checker, and then the next
|
|
|
|
;; one has all the ones after it, and so on, until the last one which
|
|
|
|
;; has no next-checker to be added. This is because flycheck next-checkers
|
|
|
|
;; must be nested if we want more than two to run. It will pick the first
|
|
|
|
;; available next-checker from next-checkers and run that after. If we want
|
|
|
|
;; a checker after that one, it must also have next-checkers configured.
|
|
|
|
(let ((checkers-to-add next-checkers))
|
|
|
|
(dolist (checker (cons primary-checker next-checkers))
|
|
|
|
(dolist (next-checker checkers-to-add)
|
|
|
|
(flycheck-add-next-checker checker next-checker t))
|
|
|
|
(setq checkers-to-add (cdr checkers-to-add))))))))
|
2019-01-14 08:19:14 +00:00
|
|
|
(spacemacs|forall-clojure-modes m
|
|
|
|
(spacemacs/enable-flycheck m)))
|
|
|
|
|
|
|
|
(defun clojure/init-flycheck-clojure ()
|
|
|
|
(use-package flycheck-clojure
|
[clojure] Added support for joker linter and having mutliple active linters
The variable clojure-enable-linters can now be set to a list of linters:
'(clj-kondo joker)
or
'(joker squiggly)
or any other combination of the available linters.
In which case, all linters in the list will be active if they are
available to be. In that flycheck is configured so that each linter
in the list has as next-checker the next linter in the list.
The variable can also now be set to:
'joker
If only the newly added joker linter should be used.
This will pull down flycheck-joker and add Joker as a checker for
Clojure modes.
--
Implementation Details
The way it works is that for each Clojure linting mode, clj, cljc,
cljs and edn, a primary linter is chosen based on the order the
user specifies in clojure-enable-linters which support that mode.
It is made the primary linter for flycheck to use by being promoted
to the front of the flycheck-checkers list. All other linters specified
by the user which the mode also supports get added to it as a
next-checker.
Tested with clj-kondo, joker and squiggly. The only issue I saw was that
the way flycheck-clojure works, and the way I currently have setup the
logic for multiple checkers mean that we can't add to a mode multiple
checkers for the same linter. flycheck-clojure has eastwood, kibit and
core.typed. If you have it configured to use eastwood linter, then it
will all work, as eastwood gets added as the next-checker. But if you
have it disabled in flycheck-clojure, there won't be any
flycheck-clojure linters to activate. I'm not sure as of now how to best
support that. Ideally, we would not clubber linters into a single packge
like that, and so the layer would have instead of squiggly: eastwood,
kibit, core.typed. But that's not how flycheck-clojure works. Future
commit might be able to do something smarter about this.
2019-09-02 07:25:45 +00:00
|
|
|
:if (configuration-layer/package-usedp 'flycheck)
|
|
|
|
:config (progn
|
|
|
|
(flycheck-clojure-setup)
|
|
|
|
(with-eval-after-load 'cider
|
|
|
|
(flycheck-clojure-inject-jack-in-dependencies)))))
|
2019-08-10 08:11:07 +00:00
|
|
|
|
|
|
|
(defun clojure/init-flycheck-clj-kondo ()
|
|
|
|
(use-package flycheck-clj-kondo
|
|
|
|
:if (configuration-layer/package-usedp 'flycheck)))
|
[clojure] Added support for joker linter and having mutliple active linters
The variable clojure-enable-linters can now be set to a list of linters:
'(clj-kondo joker)
or
'(joker squiggly)
or any other combination of the available linters.
In which case, all linters in the list will be active if they are
available to be. In that flycheck is configured so that each linter
in the list has as next-checker the next linter in the list.
The variable can also now be set to:
'joker
If only the newly added joker linter should be used.
This will pull down flycheck-joker and add Joker as a checker for
Clojure modes.
--
Implementation Details
The way it works is that for each Clojure linting mode, clj, cljc,
cljs and edn, a primary linter is chosen based on the order the
user specifies in clojure-enable-linters which support that mode.
It is made the primary linter for flycheck to use by being promoted
to the front of the flycheck-checkers list. All other linters specified
by the user which the mode also supports get added to it as a
next-checker.
Tested with clj-kondo, joker and squiggly. The only issue I saw was that
the way flycheck-clojure works, and the way I currently have setup the
logic for multiple checkers mean that we can't add to a mode multiple
checkers for the same linter. flycheck-clojure has eastwood, kibit and
core.typed. If you have it configured to use eastwood linter, then it
will all work, as eastwood gets added as the next-checker. But if you
have it disabled in flycheck-clojure, there won't be any
flycheck-clojure linters to activate. I'm not sure as of now how to best
support that. Ideally, we would not clubber linters into a single packge
like that, and so the layer would have instead of squiggly: eastwood,
kibit, core.typed. But that's not how flycheck-clojure works. Future
commit might be able to do something smarter about this.
2019-09-02 07:25:45 +00:00
|
|
|
|
|
|
|
(defun clojure/init-flycheck-joker ()
|
|
|
|
(use-package flycheck-joker
|
|
|
|
:if (configuration-layer/package-usedp 'flycheck)))
|