2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/clojure/config.el -*- lexical-binding: t; -*-
|
2017-05-30 09:28:38 +02:00
|
|
|
|
2019-10-19 15:25:29 -04:00
|
|
|
(after! projectile
|
|
|
|
(pushnew! projectile-project-root-files "project.clj" "build.boot" "deps.edn"))
|
|
|
|
|
2019-12-02 20:20:07 -05:00
|
|
|
;; Large clojure buffers tend to be slower than large buffers of other modes, so
|
|
|
|
;; it should have a lower threshold too.
|
2019-12-25 02:13:53 -05:00
|
|
|
(add-to-list 'doom-large-file-size-alist '("\\.\\(?:clj[sc]?\\|dtm\\|edn\\)\\'" . 0.5))
|
2019-12-02 20:20:07 -05:00
|
|
|
|
2019-10-19 15:25:29 -04:00
|
|
|
|
|
|
|
;;
|
|
|
|
;;; Packages
|
|
|
|
|
2020-04-23 23:49:35 -04:00
|
|
|
(use-package! clojure-mode
|
|
|
|
:hook (clojure-mode . rainbow-delimiters-mode)
|
|
|
|
:config
|
|
|
|
(when (featurep! +lsp)
|
|
|
|
(add-hook! '(clojure-mode-local-vars-hook
|
|
|
|
clojurec-mode-local-vars-hook
|
|
|
|
clojurescript-mode-local-vars-hook)
|
|
|
|
(defun +clojure-disable-lsp-indentation-h ()
|
|
|
|
(setq-local lsp-enable-indentation nil))
|
|
|
|
#'lsp!)
|
|
|
|
(after! lsp-clojure
|
|
|
|
(dolist (m '(clojure-mode
|
|
|
|
clojurec-mode
|
|
|
|
clojurescript-mode
|
|
|
|
clojurex-mode))
|
|
|
|
(add-to-list 'lsp-language-id-configuration (cons m "clojure"))))))
|
2017-05-30 09:28:38 +02:00
|
|
|
|
2019-03-02 01:56:32 -05:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! cider
|
2020-02-23 15:41:49 -05:00
|
|
|
;; NOTE if `org-directory' doesn't exist, `cider-jack' in won't work
|
2019-03-12 12:28:57 -04:00
|
|
|
:hook (clojure-mode-local-vars . cider-mode)
|
2019-10-07 20:12:41 -04:00
|
|
|
:init
|
|
|
|
(after! clojure-mode
|
2019-10-23 21:39:19 -04:00
|
|
|
(set-repl-handler! 'clojure-mode #'+clojure/open-repl :persist t)
|
|
|
|
(set-repl-handler! 'clojurescript-mode #'+clojure/open-cljs-repl :persist t)
|
2019-10-08 17:38:31 -04:00
|
|
|
(set-eval-handler! '(clojure-mode clojurescript-mode) #'cider-eval-region))
|
2019-09-13 14:01:16 -04:00
|
|
|
:config
|
|
|
|
(add-hook 'cider-mode-hook #'eldoc-mode)
|
2019-12-20 00:47:04 -05:00
|
|
|
(set-lookup-handlers! '(cider-mode cider-repl-mode)
|
2019-05-02 17:57:31 -04:00
|
|
|
:definition #'+clojure-cider-lookup-definition
|
2019-03-12 12:28:57 -04:00
|
|
|
:documentation #'cider-doc)
|
|
|
|
(set-popup-rules!
|
|
|
|
'(("^\\*cider-error*" :ignore t)
|
2021-03-27 15:54:44 -04:00
|
|
|
("^\\*cider-repl" :quit nil :ttl nil)
|
2019-03-12 12:28:57 -04:00
|
|
|
("^\\*cider-repl-history" :vslot 2 :ttl nil)))
|
2018-10-15 23:08:59 -04:00
|
|
|
|
2019-03-12 12:28:57 -04:00
|
|
|
(setq nrepl-hide-special-buffers t
|
|
|
|
nrepl-log-messages nil
|
2020-06-22 19:41:34 -03:00
|
|
|
cider-font-lock-dynamically '(macro core function var deprecated)
|
2019-03-12 12:28:57 -04:00
|
|
|
cider-overlays-use-font-lock t
|
|
|
|
cider-prompt-for-symbol nil
|
|
|
|
cider-repl-history-display-duplicates nil
|
|
|
|
cider-repl-history-display-style 'one-line
|
|
|
|
cider-repl-history-file (concat doom-cache-dir "cider-repl-history")
|
|
|
|
cider-repl-history-highlight-current-entry t
|
|
|
|
cider-repl-history-quit-action 'delete-and-restore
|
|
|
|
cider-repl-history-highlight-inserted-item t
|
|
|
|
cider-repl-history-size 1000
|
|
|
|
cider-repl-result-prefix ";; => "
|
|
|
|
cider-repl-print-length 100
|
|
|
|
cider-repl-use-clojure-font-lock t
|
|
|
|
cider-repl-use-pretty-printing t
|
|
|
|
cider-repl-wrap-history nil
|
2020-04-23 23:49:35 -04:00
|
|
|
cider-stacktrace-default-filters '(tooling dup)
|
|
|
|
|
|
|
|
;; Don't focus the CIDER REPL when it starts. Since it can take so long
|
|
|
|
;; to start up, you either wait for a minute doing nothing or be
|
|
|
|
;; prepared for your cursor to suddenly change buffers without warning.
|
|
|
|
;; See https://github.com/clojure-emacs/cider/issues/1872
|
|
|
|
cider-repl-pop-to-buffer-on-connect 'display-only)
|
2019-01-26 14:47:55 +02:00
|
|
|
|
2019-07-21 23:56:23 +02:00
|
|
|
;; Error messages emitted from CIDER is silently funneled into *nrepl-server*
|
|
|
|
;; rather than the *cider-repl* buffer. How silly. We might want to see that
|
|
|
|
;; stuff and who's going to check *nrepl-server* on every startup? I've got a
|
|
|
|
;; better idea: we copy these errors into the *cider-repl* buffer.
|
2019-07-28 14:52:59 +02:00
|
|
|
(add-hook! 'cider-connected-hook
|
2019-07-21 23:56:23 +02:00
|
|
|
(defun +clojure--cider-dump-nrepl-server-log-h ()
|
|
|
|
"Copy contents of *nrepl-server* to beginning of *cider-repl*."
|
2019-10-30 18:33:00 +08:00
|
|
|
(when (buffer-live-p nrepl-server-buffer)
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-min))
|
|
|
|
(insert
|
|
|
|
(with-current-buffer nrepl-server-buffer
|
|
|
|
(buffer-string)))))))
|
2019-07-21 23:56:23 +02:00
|
|
|
|
2021-02-07 02:30:04 +00:00
|
|
|
;; When in cider-debug-mode, override evil keys to not interfere with debug keys
|
|
|
|
(after! evil
|
|
|
|
(add-hook! cider--debug-mode
|
|
|
|
(defun +clojure--cider-setup-debug ()
|
|
|
|
"Setup cider debug to override evil keys cleanly"
|
|
|
|
(evil-make-overriding-map cider--debug-mode-map 'normal)
|
|
|
|
(evil-normalize-keymaps))))
|
|
|
|
|
2020-06-05 21:42:36 -03:00
|
|
|
(when (featurep! :ui modeline +light)
|
|
|
|
(defvar-local cider-modeline-icon nil)
|
|
|
|
|
|
|
|
(add-hook! '(cider-connected-hook
|
|
|
|
cider-disconnected-hook
|
|
|
|
cider-mode-hook)
|
|
|
|
(defun +clojure--cider-update-modeline ()
|
|
|
|
"Update modeline with cider connection state."
|
|
|
|
(let* ((connected (cider-connected-p))
|
|
|
|
(face (if connected 'success 'warning))
|
|
|
|
(label (if connected "Cider connected" "Cider disconnected")))
|
|
|
|
(setq cider-modeline-icon (concat
|
|
|
|
" "
|
|
|
|
(+modeline-format-icon 'faicon "terminal" "" face label -0.0575)
|
|
|
|
" "))
|
|
|
|
(add-to-list 'global-mode-string
|
2020-06-16 18:13:48 -03:00
|
|
|
'(t (:eval cider-modeline-icon))
|
2020-06-05 21:42:36 -03:00
|
|
|
'append)))))
|
|
|
|
|
2019-07-21 23:56:23 +02:00
|
|
|
;; The CIDER welcome message obscures error messages that the above code is
|
|
|
|
;; supposed to be make visible.
|
|
|
|
(setq cider-repl-display-help-banner nil)
|
|
|
|
|
2019-03-12 12:28:57 -04:00
|
|
|
(map! (:localleader
|
2019-07-29 09:17:14 +02:00
|
|
|
(:map (clojure-mode-map clojurescript-mode-map)
|
|
|
|
"'" #'cider-jack-in-clj
|
2019-07-29 01:23:18 +08:00
|
|
|
"\"" #'cider-jack-in-cljs
|
2019-07-29 09:17:14 +02:00
|
|
|
"c" #'cider-connect-clj
|
|
|
|
"C" #'cider-connect-cljs
|
2020-04-17 15:44:14 -04:00
|
|
|
"m" #'cider-macroexpand-1
|
|
|
|
"M" #'cider-macroexpand-all
|
2021-02-07 02:30:04 +00:00
|
|
|
(:prefix ("d" . "debug")
|
|
|
|
"d" #'cider-debug-defun-at-point)
|
2019-03-12 12:28:57 -04:00
|
|
|
(:prefix ("e" . "eval")
|
2019-10-04 17:49:28 -04:00
|
|
|
"b" #'cider-eval-buffer
|
2019-03-12 12:28:57 -04:00
|
|
|
"d" #'cider-eval-defun-at-point
|
|
|
|
"D" #'cider-insert-defun-in-repl
|
|
|
|
"e" #'cider-eval-last-sexp
|
|
|
|
"E" #'cider-insert-last-sexp-in-repl
|
|
|
|
"r" #'cider-eval-region
|
|
|
|
"R" #'cider-insert-region-in-repl
|
|
|
|
"u" #'cider-undef)
|
2019-10-04 17:49:28 -04:00
|
|
|
(:prefix ("g" . "goto")
|
2019-03-12 12:28:57 -04:00
|
|
|
"b" #'cider-pop-back
|
|
|
|
"g" #'cider-find-var
|
|
|
|
"n" #'cider-find-ns)
|
|
|
|
(:prefix ("h" . "help")
|
|
|
|
"n" #'cider-find-ns
|
|
|
|
"a" #'cider-apropos
|
2019-12-18 15:25:35 -05:00
|
|
|
"c" #'cider-clojuredocs
|
2019-03-12 12:28:57 -04:00
|
|
|
"d" #'cider-doc
|
2019-12-18 15:25:35 -05:00
|
|
|
"j" #'cider-javadoc
|
|
|
|
"w" #'cider-clojuredocs-web)
|
2019-03-12 12:28:57 -04:00
|
|
|
(:prefix ("i" . "inspect")
|
2019-07-29 09:17:14 +02:00
|
|
|
"e" #'cider-enlighten-mode
|
2019-03-12 12:28:57 -04:00
|
|
|
"i" #'cider-inspect
|
|
|
|
"r" #'cider-inspect-last-result)
|
|
|
|
(:prefix ("n" . "namespace")
|
|
|
|
"n" #'cider-browse-ns
|
2019-10-04 17:49:28 -04:00
|
|
|
"N" #'cider-browse-ns-all
|
|
|
|
"r" #'cider-ns-refresh)
|
2021-01-03 15:43:44 -08:00
|
|
|
(:prefix ("p" . "print")
|
|
|
|
"p" #'cider-pprint-eval-last-sexp
|
|
|
|
"P" #'cider-pprint-eval-last-sexp-to-comment
|
|
|
|
"d" #'cider-pprint-eval-defun-at-point
|
|
|
|
"D" #'cider-pprint-eval-defun-to-comment
|
|
|
|
"r" #'cider-pprint-eval-last-sexp-to-repl)
|
2019-03-12 12:28:57 -04:00
|
|
|
(:prefix ("r" . "repl")
|
|
|
|
"n" #'cider-repl-set-ns
|
|
|
|
"q" #'cider-quit
|
2020-01-06 16:57:26 +00:00
|
|
|
"r" #'cider-ns-refresh
|
2019-03-12 12:28:57 -04:00
|
|
|
"R" #'cider-restart
|
|
|
|
"b" #'cider-switch-to-repl-buffer
|
|
|
|
"B" #'+clojure/cider-switch-to-repl-buffer-and-switch-ns
|
2019-07-24 13:15:07 -05:00
|
|
|
"c" #'cider-find-and-clear-repl-output
|
|
|
|
"l" #'cider-load-buffer
|
|
|
|
"L" #'cider-load-buffer-and-switch-to-repl-buffer)
|
|
|
|
(:prefix ("t" . "test")
|
|
|
|
"a" #'cider-test-rerun-test
|
|
|
|
"l" #'cider-test-run-loaded-tests
|
|
|
|
"n" #'cider-test-run-ns-tests
|
|
|
|
"p" #'cider-test-run-project-tests
|
|
|
|
"r" #'cider-test-rerun-failed-tests
|
|
|
|
"s" #'cider-test-run-ns-tests-with-filters
|
|
|
|
"t" #'cider-test-run-test)))
|
2017-11-03 19:28:05 -04:00
|
|
|
|
2019-04-21 19:59:44 -04:00
|
|
|
(:when (featurep! :editor evil +everywhere)
|
2019-03-12 12:28:57 -04:00
|
|
|
:map cider-repl-mode-map
|
|
|
|
:i [S-return] #'cider-repl-newline-and-indent
|
2019-07-29 09:17:14 +02:00
|
|
|
:i [M-return] #'cider-repl-return
|
2019-04-18 20:59:46 -03:00
|
|
|
(:localleader
|
2019-10-08 17:40:39 -04:00
|
|
|
"n" #'cider-repl-set-ns
|
|
|
|
"q" #'cider-quit
|
|
|
|
"r" #'cider-ns-refresh
|
|
|
|
"R" #'cider-restart
|
|
|
|
"c" #'cider-repl-clear-buffer)
|
2019-03-12 12:28:57 -04:00
|
|
|
:map cider-repl-history-mode-map
|
|
|
|
:i [return] #'cider-repl-history-insert-and-quit
|
|
|
|
:i "q" #'cider-repl-history-quit
|
|
|
|
:i "l" #'cider-repl-history-occur
|
|
|
|
:i "s" #'cider-repl-history-search-forward
|
|
|
|
:i "r" #'cider-repl-history-search-backward
|
|
|
|
:i "U" #'cider-repl-history-undo-other-window)))
|
2018-09-07 20:35:29 -07:00
|
|
|
|
2019-03-12 12:28:57 -04:00
|
|
|
|
2020-04-16 21:33:02 -04:00
|
|
|
(after! cider-doc
|
|
|
|
;; Fixes raxod502/radian#446: CIDER tries to do color calculations when it's
|
|
|
|
;; loaded, sometimes too early, causing errors. Better to wait until something
|
|
|
|
;; is actually rendered.
|
|
|
|
(setq cider-docview-code-background-color nil)
|
|
|
|
|
|
|
|
(defadvice! +clojure--defer-color-calculation-a (&rest _)
|
|
|
|
"Set `cider-docview-code-background-color'.
|
|
|
|
This is needed because we have ripped out the code that would normally set it
|
|
|
|
(since that code will run during early init, which is a problem)."
|
|
|
|
:before #'cider-docview-fontify-code-blocks
|
|
|
|
(setq cider-docview-code-background-color (cider-scale-background-color)))
|
|
|
|
|
|
|
|
;; HACK Disable cider's advice on these; and hope no one else is using these
|
|
|
|
;; old-style advice.
|
|
|
|
(ad-deactivate #'enable-theme)
|
|
|
|
(ad-deactivate #'disable-theme))
|
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! clj-refactor
|
2019-03-12 12:28:57 -04:00
|
|
|
:hook (clojure-mode . clj-refactor-mode)
|
2019-09-13 14:01:16 -04:00
|
|
|
:config
|
2019-04-24 18:03:56 +03:00
|
|
|
(set-lookup-handlers! 'clj-refactor-mode
|
2019-03-12 12:28:57 -04:00
|
|
|
:references #'cljr-find-usages)
|
|
|
|
(map! :map clojure-mode-map
|
|
|
|
:localleader
|
|
|
|
:desc "refactor" "R" #'hydra-cljr-help-menu/body))
|
|
|
|
|
|
|
|
|
2019-12-29 00:37:40 +08:00
|
|
|
(use-package! flycheck-clj-kondo
|
2020-01-14 03:04:26 -05:00
|
|
|
:when (featurep! :checkers syntax)
|
2019-03-12 12:28:57 -04:00
|
|
|
:after flycheck)
|